Skip to content

Latest commit

 

History

History
37 lines (34 loc) · 1018 Bytes

bubble-sort-output-steps.md

File metadata and controls

37 lines (34 loc) · 1018 Bytes

Bubble Sort Algorithm

Stepwise Implementation of the Bubble Sort Algorithm

If the input is [6,2,9,5,1,3] the steps are:

compare 6 and 2 - swap
compare 6 and 9 - no change
compare 9 and 5 - swap
compare 9 and 1 - swap
compare 9 and 3 - swap
REPEAT ITERATION
compare 2 and 6 - no change
compare 6 and 5 - swap 
compare 6 and 1 - swap
compare 6 and 3 - swap
REPEAT ITERATION
compare 2 and 5 - no change
compare 5 and 1 - swap
compare 5 and 3 - swap
REPEAT ITERATION
compare 2 and 1 - swap
compare 2 and 3 - no change
REPEAT ITERATION 
compare 1 and 2 - no change
FINISH

If the input is [1,2,9,3,10,7] steps are:

compare 1 and 2 - no change
compare 2 and 9 - no change
........
  • Your task is to complete the remaining steps for the input [1,2,9,3,10,7].
  • Please Note that you dont need to perform any further iterations if there is no swap made in the current iteration.