An astronomer is designing a search system for a stellar database. The system uses a binary search algorithm to locate constellations by name.
Here is the algorithm's pseudocode:
constellations = ["Andromeda", "Aquila", "Cygnus", "Gemini", "Lyra", "Orion", "Pegasus", "Taurus", "Ursa"]
target = input("Enter constellation name: ")
found = False
start = 0
finish = 8
while found == False and start <= finish
mid = (start + finish) DIV 2
if constellations[mid] == target then
found = True
else if target > constellations[mid] then
start = mid + 1
else
finish = mid - 1
endif
endwhile
Complete the trace table below for this algorithm if the user inputs "Orion".
The first row has already been set up for you.
| target | found | start | finish | mid |
|---|---|---|---|---|
| "Orion" | False | 0 | 8 | 4 |
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.