Question bank › GCSE Computer Science › Algorithms

Searching algorithms: linear and binary search

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

1Grade 1–33 marks

(a) State one requirement that the data must meet before a binary search can be used. [1]

(b) Give one advantage of a linear search over a binary search. [1]

(c) A linear search is carried out on an unsorted list of 1000 items. State the maximum number of items that may need to be checked. [1]

2Grade 4–53 marks

A list of numbers is shown.

[3, 8, 12, 19, 25, 34, 41, 47, 50]

Show the stages of a binary search to find the number 34. [3]

3Grade 6–75 marks

Write a function called linearSearch that:

• takes an array items and a value target as parameters

• returns the index of the first position where target is found

• returns -1 if target is not in the array.

Do not use a built-in search function.

Use OCR Exam Reference Language or a high-level programming language. [5]

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