AS June 2023 Q1
1.
| 67 | 59 | 46 | 71 | 40 | 48 | 53 | 63 | 45 | 54 | 56 |
The list of eleven numbers shown above is to be sorted into descending order.
Carry out a quick sort to produce the sorted list. You should show the result of each pass and identify the pivots clearly.
| Scheme | Marks | AO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| M1 A1 A1ft A1 | 1.1b 1.1b 1.1b 1.1b | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (4 marks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Notes
M1: Quick Sort, pivot, p, chosen (must be choosing middle right or middle left). After the first pass the list must read (values greater than the pivot), pivot, (values less than the pivot). If choosing only one pivot per iteration, then M1 only. Their original list of 10, 11 or 12 numbers must be a list of 10, 11 or 12 numbers after the first pass
A1: First two passes correct (pivots for third pass need not be chosen)
A1ft: Third and fourth passes correct (follow through from their second pass and choice of consistent pivots) (pivot(s) for the fifth pass need not be chosen). After their second pass their list must contain either 10, 11 or 12 numbers (so allow one additional/missing number)
A1: cso – if choosing middle right pivots then they must include a fifth pass and if choosing middle left then they must include a sixth pass
SC: If list is sorted into ascending order, then award a maximum of M1A1A0A0 (so 2 marks) as in the scheme above even if the list is re-ordered after the sort is complete
Ascending:
| 67 | 59 | 46 | 71 | 40 | 48 | 53 | 63 | 45 | 54 | 56 |
| 46 | 40 | 45 | \(\underline{48}\) | 67 | 59 | 71 | 53 | 63 | 54 | 56 |
| \(\underline{40}\) | 46 | 45 | \(\underline{48}\) | \(\underline{53}\) | 67 | 59 | 71 | 63 | 54 | 56 |