logo

Question detail

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, check the answer, then read the explanation to understand the curriculum point.

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

Model answer

What a good answer should say

  • 3 comparisons, index 2

Explanation

Why this works

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

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.