D1 June 2006 Q1
1.
52 48 50 45 64 47 53
The list of numbers above is to be sorted into descending order. Perform a bubble sort to obtain the sorted list, giving the state of the list after each completed pass. (4)
| Scheme | Marks | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e.g.
| M1 A1 A1ft A1 | ||||||||||||||||||||||||||||||||||||||||||
| (4 marks) |
Notes
M1 Bubble sort – 1st pass complete – end term 45 or 64, consistent L→R or R→L. Shuttle, Quick etc get M0
A1 First 2 passes correct
A1ft Next 2 passes correct (ft if L←R next pass) (condone ‘shrinking’ list)
A1 Final pass + final statement/rewrites list cso – must see whole list