Question bank › GCSE Computer Science › Fundamentals of algorithms

Searching algorithms: linear & binary search

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 4–54 marks

A binary search is used to find the value 63 in this sorted list:

[4, 9, 15, 22, 28, 33, 41, 50, 56, 63, 70]

(a) List, in order, each value that is compared with 63 during the search. [3]

(b) Explain why a binary search could not be used on the list [22, 4, 70, 9, 41]. [1]

2Grade 8–96 marks

An array names holds a list of student names. Write an algorithm, using either pseudo-code or program code in the language you are studying (C#, Python or VB.NET), that:

  • asks the user to enter a name to search for
  • uses a linear search to find the first position of that name in names
  • outputs the index of the name if it is found, or outputs −1 if it is not in the array
  • stops searching as soon as the name is found.

[6]

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro