Bubble sorting an array A[0, 1, 2, ..., n-1]
01 BubbleSort(A[0, 1, 2, ..., n-1])
02 i <- 0 03 repeat 04 exch <- False 05 for (j <- 0) to (n-2-i) do 06 if A[j] > A[j+1] then
07 exchange A[j] <-> A[j+1]
08 exch <- True
09 end if
10 end for
11 i <- i+1
12 Until exch = False
Click here for explanation on what is bubble sort?
Showing posts with label BubbleSort. Show all posts
Showing posts with label BubbleSort. Show all posts
Monday, February 9, 2009
Subscribe to:
Posts (Atom)