previous | start | next

Bubble Sort for an array of size 3

For simplicity, assume there are no duplicates and consider an array of size 3:

      A[0] = v1
      A[1] = v2
      A[2] = v3
   

where the three values v1, v2, v3 are the values 1, 2, 3 in some order

Bubble sort must sort them so that the result is

      A[0] = 1
      A[1] = 2
      A[2] = 3
   

for each possible ordering v1, v2, v3 of 1, 2, 3.

Which of the values {v1, v2, v3} are compared by the first comparison of Bubble.sort?



previous | start | next