Also called Shaker sort and Bidirectional bubble sort.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from cocktail shaker sort's own run on the numbers shown.
choose one
1question 1
Cocktail shaker sort works on 3, 9, 5, 1, 4, 8. What is the row after its first two walks, one right and one back left?
the answer, and why
the answer is B
After walk 1 the 9 stands at the end: 3, 5, 1, 4, 8, 9. After walk 2, going back left, the 1 stands at the front: 1, 3, 5, 4, 8, 9.
if you chose another
AThat is the row after walk 1 only.
CThat is two walks to the right, as bubble sort makes them.
DThat is the row sorted. Two walks promise only that the biggest and the smallest reach their ends.