Computer Science, asked by munakalasiva016, 9 days ago

01. If you are using Bubble sort for sorting the given numbers in ascending order then find out the number of swappings needed. 3,5, 1, 4,2 Ops: A. 4 B. 5 C. 03 D. 6 Reset​

Answers

Answered by hotguys69
2

Explanation:

The following concentration were obtained for the formation of NH3 from N2 and H2 at equilibrium at 500 K.[N2(g)] = 1.5 x 10-2 M [H2 (g)] = 3.0 x 10-2 M [NH3] = 1.2 x 10-2 M. Calculate equilibrium constant. * 53 0.035 3.55 53.55

Answered by ankhidassarma9
0

Answer:

There are 5 numbers in the given list 3,5, 1, 4,2  . number of swapping needed is 5.

Explanation:

  • If there are 5 elements in the list then to sort the entire list/array we need 5-1 i.e. 4 passes.
  • pass 1:     3,5, 1, 4,2

                  compare 3 with 5 :   no swapping

                  compare 5 with 1:      swapping (3,1,5,4,2)

                  compare 5 with 4:      swapping (3,1,4,5,3)

                  compare 5 with 3:      swapping (3,1,4,3,5)

  After pass 1 we will get a new list/array 3,1,4,3,5   which will now go to pass2.

  • pass 2 :    3,1,4,3,5

                  compare 3 with 1 :      swapping(1,3,4,3,5)

                  compare 3 with4:      no swapping (1,3,4,3,5)

                  compare 4 with 3:      swapping (1,3,3,4,5)

                  compare 4 with 5:     no swapping (1,3,3,4,5)

  • After pass 2 we will get a new list/array (1,3,3,4,5)   which will now go to pass3.
  • This list is already sorted so in pass3 there will be no swapping and same will happen in pass 4.
  • hence the total number of swapping is 4 passes are 5(3 times in pass 1 and 2 times in pass 2).
Similar questions