Created
October 4, 2010 17:41
-
-
Save thinkphp/610123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Algorithm B (Bubble Sort). Records R(1),...,R(N) are rearranged | |
| in place; after sorting is complete their keys will be in | |
| order, K(1)<=K(2)<= ...<=K(N). | |
| 1. Set BOUND <-- N (BOUND is the highest index for which | |
| the record is known to be in its final position). | |
| 2. Set t <-- 0, Perform step 3 for j=1,2,...,BOUND - 1, and then go to step 4 | |
| 3. If K(j) > K(j+1) , interchange R(j) <--> R(j+1) and set t <-- j. | |
| 4. If t = 0 , the algorithm terminates, otherwise set BOUND <-- t | |
| and return to step 2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment