Linear vs. Binary Search

An algorithm's efficiency is measured by how the number of execution steps grows as input size N increases: (1) Linear.

What to practice

  • Compute exact maximum comparisons for Linear Search and Binary Search on lists of size N.
  • Classify algorithmic step counts as reasonable (polynomial) vs. unreasonable (exponential/factorial).
  • Explain when to apply a heuristic and distinguish intractable optimization problems from undecidable problems (Halting Problem).

1. Core Concept Instruction

An algorithm's efficiency is measured by how the number of execution steps grows as input size N increases: (1) Linear vs. Binary Search: Linear search works on any list and takes at most N comparisons. Binary search requires the list to be SORTED and repeatedly checks the middle element, taking at most floor(log_2 N) + 1 comparisons (e.g., for N = 1,000,2^(10) = 1,024, so binary search takes at most 10 comparisons; doubling N to 2,000 adds only 1 extra comparison!). (2) Reasonable vs. Unreasonable Time: Algorithms whose steps grow as a polynomial function of N (such as N, N^2, N^3) run in 'reasonable time'. Algorithms whose steps grow exponentially (2^N) or factorially (N!) run in 'unreasonable time' for large N. (3) Heuristics: When an exact optimization problem (like the Traveling Salesperson Problem) requires unreasonable time, programmers use a heuristic—an approximate strategy (like nearest-neighbor) that runs in reasonable time and finds a good, near-optimal solution, though not guaranteed to be the absolute best. (4) Undecidable Problems: A problem (like Alan Turing's Halting Problem) for which NO algorithm can ever be constructed that always gives a correct yes/no answer for all possible inputs.

2. Worked Examples

Worked Binary Search Step Calculation & Reasonable vs. Unreasonable Runtime Classification

(a) A sorted list contains 2,500 customer IDs. What is the maximum number of elements examined by Binary Search vs. Linear Search? (b) Classify four algorithms with step counts 50*N^2, 3*N^3 + 100*N, 2^N, and 10*N as reasonable or unreasonable.

Result:

Reasonable (Polynomial) vs. Unreasonable (Exponential) Runtime & Heuristic Trade-offs

Compare an algorithm requiring 2^n steps against one requiring 5n^3 steps for n = 40, and explain why a delivery company uses a greedy nearest-neighbor heuristic for the Traveling Salesperson Problem (TSP).

Result: 5n^3 is polynomial (reasonable time); 2^n is exponential (unreasonable time), motivating a fast heuristic

Core Concept Review

An algorithm's efficiency is measured by how the number of execution steps grows as input size N increases: (1) Linear vs. Binary Search: Linear search works on any list and takes at most N comparisons. Binary search requires the list to be SORTED and repeatedly checks the middle element, taking at most floor(log_2 N) + 1 comparisons (e.g., for N = 1,000,2^(10) = 1,024, so binary search takes at most 10 comparisons; doubling N to 2,000 adds only 1 extra comparison!). (2) Reasonable vs. Unreasonable Time: Algorithms whose steps grow as a polynomial function of N (such as N, N^2, N^3) run in 'reasonable time'. Algorithms whose steps grow exponentially (2^N) or factorially (N!) run in 'unreasonable time' for large N. (3) Heuristics: When an exact optimization problem (like the Traveling Salesperson Problem) requires unreasonable time, programmers use a heuristic—an approximate strategy (like nearest-neighbor) that runs in reasonable time and finds a good, near-optimal solution, though not guaranteed to be the absolute best. (4) Undecidable Problems: A problem (like Alan Turing's Halting Problem) for which NO algorithm can ever be constructed that always gives a correct yes/no answer for all possible inputs.

Extended Concept Analysis

An algorithm's efficiency is measured by how the number of execution steps grows as input size N increases: (1) Linear vs. Binary Search: Linear search works on any list and takes at most N comparisons. Binary search requires the list to be SORTED and repeatedly checks the middle element, taking at most floor(log_2 N) + 1 comparisons (e.g., for N = 1,000,2^(10) = 1,024, so binary search takes at most 10 comparisons; doubling N to 2,000 adds only 1 extra comparison!). (2) Reasonable vs. Unreasonable Time: Algorithms whose steps grow as a polynomial function of N (such as N, N^2, N^3) run in 'reasonable time'. Algorithms whose steps grow exponentially (2^N) or factorially (N!) run in 'unreasonable time' for large N. (3) Heuristics: When an exact optimization problem (like the Traveling Salesperson Problem) requires unreasonable time, programmers use a heuristic—an approximate strategy (like nearest-neighbor) that runs in reasonable time and finds a good, near-optimal solution, though not guaranteed to be the absolute best. (4) Undecidable Problems: A problem (like Alan Turing's Halting Problem) for which NO algorithm can ever be constructed that always gives a correct yes/no answer for all possible inputs.

Worked Problem Walkthrough

Worked Binary Search Step Calculation & Reasonable vs. Unreasonable Runtime Classification

(a) A sorted list contains 2,500 customer IDs. What is the maximum number of elements examined by Binary Search vs. Linear Search? (b) Classify four algorithms with step counts 50N^2, 3N^3 + 100N, 2^N, and 10N as reasonable or unreasonable.

Reasonable (Polynomial) vs. Unreasonable (Exponential) Runtime & Heuristic Trade-offs

Compare an algorithm requiring 2^n steps against one requiring 5n^3 steps for n = 40, and explain why a delivery company uses a greedy nearest-neighbor heuristic for the Traveling Salesperson Problem (TSP).

Common Exam Traps & How to Avoid Them

  • Using Binary Search on a list that is not sorted in ascending or descending order.

  • Thinking that a heuristic guarantees finding the single optimal solution, or that an undecidable problem can be solved by buying a faster supercomputer.

Key Vocabulary

  • Heuristic: A practical problem-solving approach that produces a sufficiently good approximate solution in reasonable time when finding an exact optimal solution is impractical.

  • Undecidable Problem: A decision problem for which it is mathematically impossible to write an algorithm that gives a correct yes/no output for every possible input (e.g., the Halting Problem).

Use this chapter companion

Review the lesson, attempt the original practice, then check the explanation. Your printed study guide remains complete without the website.

Independence

Skill by Skill Prep is independent. SAT® and AP® are trademarks registered by the College Board, which is not affiliated with, and does not endorse, this website or book. PSAT/NMSQT® is a registered trademark of the College Board and the National Merit Scholarship Corporation, which are not affiliated with, and do not endorse, this site. Bluebook™ is a trademark of the College Board. ACT® is a trademark of ACT Education Corp., which is not affiliated with and does not endorse this website or book. Desmos is a trademark of Desmos Studio PBC. Practice results describe these questions, not official scores or admission predictions.

Last updated .