D1 June 2013 (R) Q4

EdexcelOld spec8 marksAlgorithms

4.

1. Sam (S)
2. Janelle (J)
3. Haoyu (H)
4. Alfie (A)
5. Cyrus (C)
6. Komal (K)
7. Polly (P)
8. David (D)
9. Tom (T)
10. Lydia (L)

A binary search is to be performed on the names in the list above to locate the name Lydia.

(a) Using an appropriate algorithm, rearrange the list so that a binary search can be performed, showing the state of the list after each complete iteration. State the name of the algorithm you have used. (4)
(b) Use the binary search algorithm to locate the name Lydia in the list you obtained in (a). You must make your method clear. (4)