logo

AQA A-Level Computer Science practice

A linear search examines the list [14, 6, 21, 9] for the value 21. How many comparisons are made, and at which zero-based index is the value found?

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Searching algorithms

Exam-style question

Try this first

A linear search examines the list [14, 6, 21, 9] for the value 21. How many comparisons are made, and at which zero-based index is the value found?.

  1. A.2 comparisons, index 1
  2. B.3 comparisons, index 2
  3. C.3 comparisons, index 3
  4. D.4 comparisons, index 2

Answer and explanation

Concise answer

3 comparisons, index 2

Why this is correct

The search compares 21 with 14, then 6, then 21. Therefore, three comparisons are made and the value is at zero-based index 2.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions