Skip to content

Study guides & original practice

Linear versus binary search practice

Linear search checks candidates sequentially. Binary search repeatedly discards half of a sorted search interval, so its preconditions are part of the algorithm.

By ExamCat · Original study lesson · Published September 24, 2026

Understand the method

For an ordinary random-access sorted array, binary search uses logarithmically many comparisons in the worst case, while linear search can inspect every item. Sorting an unsorted collection has a cost; do not ignore it when comparing one-time searches.

Worked example, step by step

Search for 14 in the sorted array [2, 5, 8, 11, 14, 17, 20] using zero-based indices.

  1. The initial middle index is 3, containing 11.
  2. Because 14 is larger, keep indices 4 through 6.
  3. The next middle index is 5, containing 17; keep index 4.
  4. Index 4 contains 14. This run finds the target in three comparisons.

A mistake to watch for

Binary search cannot safely discard half of an arbitrary unsorted list using a midpoint comparison. For duplicates, finding any match differs from finding the first or last match.

Try it yourself: three questions

Write an answer before opening the explanation. For calculations, keep your units and intermediate steps; for concepts, state the reason for your choice.

1. What can linear search do that basic binary search cannot assume?

Show answer and explanation

It can search an unsorted sequence without first organizing it by value.

2. Why must the search interval shrink after a nonmatching comparison?

Show answer and explanation

Otherwise the same middle element can be examined forever, causing an infinite loop.

3. If a sorted array grows from 1,024 to 2,048 items, does binary search need twice as many comparisons?

Show answer and explanation

No. Halving-based search generally needs about one extra level, while exact counts depend on the implementation and outcome.

Build your next practice session

Mark the first step where your reasoning differed from the explanation. Turn that step into a question, answer it without looking, then change one condition in the example and explain what would change. A correct guess is a reason to revisit the method.

Use the free flashcard maker for your own question-and-answer pairs, or bring your course material into PDF-to-flashcards practice.

Further reading

OpenStax: sample searching algorithms provides textbook background. The worked scenario and practice questions on this page were written independently for ExamCat.

Related lessons

Browse this subject in the Blog ↗

Practice your own class material

Generate flashcards, notes and quizzes from your lecture notes in Exam Cat.

Try 7 days free ↗

Yearly plan: 7 days free, then $39.99/year. Cancel before the trial ends to avoid a charge.

APUSH study guide · Biology study guide · APUSH practice · All study tools