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, 6, 2, 5, 1, 4. What is the row after its first two walks, one right and one back left?
the answer, and why
the answer is A
Walk 1 carries the 6 to the end, leaving 3, 2, 5, 1, 4, 6. Walk 2 goes left from the 4, and the 1 swaps past the 5, the 2 and the 3. The 5 lands beside the 4 only after walk 2 has passed places 4 and 5, so the 5 and the 4 stay the wrong way round.
3, 6, 2, 5, 1, 4, walk by walk.
if you chose another
BThat is the row after walk 1 only.
CThat is two walks to the right, as bubble sort makes them.