A communications satellite logs a series of unique, sorted signal frequencies (in kHz) received during a transit. The recorded frequencies are stored in a 1-dimensional array, indexed from 0 to 8:
| Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|---|
| Frequency | 104 | 112 | 125 | 131 | 145 | 168 | 172 | 189 | 195 |
An engineer uses a standard binary search algorithm to locate the frequency 168 kHz in this array. The algorithm calculates the midpoint index at each stage using integer division:
midpoint=⌊lower bound+upper bound2⌋ \text{midpoint} = \lfloor\frac{\text{lower bound} + \text{upper bound}}{2}\rfloor midpoint=⌊2lower bound+upper bound⌋State, in order, the frequencies from the array that are compared with the target frequency of 168 kHz during this search.
33 exam-style questions on AQA GCSE Computer Science Searching algorithms. Each one has a worked solution and a mark scheme showing where the marks go.