Back to the full dot-point answer
SingaporeComputer ScienceQuick questions
Algorithms and Problem Solving
Quick questions on Searching algorithms explained: O-Level Computing
6short Q&A pairs drawn directly from our worked dot-point answer. For full context and worked exam questions, read the parent dot-point page.
What is linear search?Show answer
A linear search starts at the first item and checks each one in turn until it finds the target or runs out of items.
What is binary search?Show answer
A binary search works only on a sorted list. It checks the middle item, then discards the half that cannot contain the target:
What is not halving correctly?Show answer
After each comparison, keep only the half that could contain the target, then find the new middle of that half.
What is q1?Show answer
State one advantage of linear search over binary search. [2 marks]
What is q2?Show answer
A sorted list has items. State the maximum number of comparisons a binary search needs. [2 marks]
What is q3?Show answer
Explain why binary search needs the list to be sorted. [2 marks]
Have a question we have not covered?
This dot-point answer is short enough that we have not extracted many short questions yet. Read the full dot-point answer or ask Mo, our study assistant, in the chat for follow ups.