Unformatted text preview: arch is restricted to the 13th position and above. 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 3. The midpoint of the current list is now the 14th position with a value of 19. Since 19 ≯ 19, further search is restricted to the portion from the 13th through the 14th positions 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 4. The midpoint of the current list is now the 13th position with a value of 18. Since 19> 18, search is restricted to the portion from the 18th position through the 18th. 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 5. Now the list has one element and the loop ends. Since 19=19, the location 16 is returned. Bubble Sort procedure bubblesort (a1,…,an: real numbers with n ≥ 2) for i := 1 to n− 1 for j := 1 to n − i if aj > aj+1 then interchange aj and aj+1 http://www.cs.armstrong.edu/liang/animation/BubbleSortAnimation.html Inser$on Sort ༉ Insertion sort begins with the 2nd element. The algorithm then selects each element and put it in its proper...
View
Full Document
 Spring '14
 M.Nojoumian
 Algorithms, Sort

Click to edit the document details