Sorting Algorithms Flashcards
1
Q
Bubble Sort
A
for outer = (listLength - 1) to 0 step -1 For inner = 0 to outer if list(inner) > list(inner+1) then Swap values End if Next inner Next outer
2
Q
Insertion Sort
A
Set current to 0 Set position to 0 For counter = 1 to (listlength-1) Set current to list(counter) Set position to counter WHILE (position > 0) AND list(position -1) < current DO SET list(position) TO list(position-1) Set position to position - 1 END WHILE Set list(position) TO current END FOR