Compare growth of linear, quadratic, and exponential functions
Apply efficiency reasoning to choose between algorithm strategies
📈
Exam Impact: Algorithmic efficiency is a conceptual BI3 topic that connects to BI4 parallel computing and BI5 impact questions.
💡 Why This Matters
Adding a faster processor makes your program run 10x faster. But an exponential algorithm barely benefits: a problem that took a billion years now takes 100 million years. Efficiency is about the algorithm, not just the hardware.
Reasonable vs Unreasonable Time
Reasonable (polynomial): n, n², n³, log n -- grows manageably with input size. Unreasonable (exponential): 2⊃n⊃, n! -- grows so fast that even small inputs become unsolvable.
An exponential algorithm for n=100 produces more steps than atoms in the observable universe.
# Linear: O(n) -- checks each element once
def linear_search(lst, target):
for item in lst:
if item == target:
return True
return False
# Binary: O(log n) -- much faster on sorted data
{Polynomial examples:}
{Linear: n steps}
{Binary search: log n steps}
{Bubble sort: n^2 steps}
{Exponential:}
{2^n grows too fast for large n}
10x faster hardware adds only log⊂2⊂(10) ≈ 3 more usable input size for an exponential algorithm. For polynomial algorithms, 10x speedup translates to a meaningful improvement in problem size handled.
Practice Problems
🔎 Practice MCQ
An algorithm requiring 2⊃n⊃ steps is classified as:
🔎 Practice MCQ
A computer runs 10x faster. An algorithm requiring 2⊃n⊃ steps reaches its limit at approximately:
⚠️ Predict your answer BEFORE clicking.
🔎 Practice MCQ
Which algorithm classification is NOT considered reasonable? I. O(n) linear II. O(n²) quadratic III. O(2⊃n⊃) exponential
⚠️ Predict your answer BEFORE clicking.
🎮 Game
Efficiency Classifier
Classify each algorithm as reasonable or unreasonable. 8 questions.
0
Correct
1/8
Question
0
Streak 🔥
🤔 Evaluate:
0/8
correct
💻 Python Code Editor
Practice Problems
Write Python and check your answer. Paste into Replit for complex programs.
Problem 1 of 3
How many steps does a linear search need in worst case for a list of 100 elements? Print the number. Expected: 100
Hint: Linear search checks up to n elements. For 100 elements, worst case = 100 checks.
Problem 2 of 3
Print the max comparisons binary search needs for a list of 128 elements. Expected: 7
Hint: log2(128)=7.
Problem 3 of 3
Spot the inefficiency: this O(n^2) duplicate check can be O(n). Print found using a set. for i in range(len(nums)): for j in range(len(nums)): if i!=j and nums[i]==nums[j]: print('found')
Hint: len(set(nums)) removes duplicates. If it differs from len(nums), a duplicate exists. O(n) instead of O(n^2).
Frequently Asked Questions
O(n) is Big-O notation for 'order of n.' It describes how step count grows as n increases. O(n)=linear. O(n^2)=quadratic. The AP exam tests the concept without requiring formal Big-O.
Both are polynomial (reasonable) but O(n^3) grows faster. The key AP exam distinction is polynomial vs exponential.
Yes. Heuristics find good-enough answers in polynomial time when exact exponential solutions are infeasible. The AP exam acknowledges this.
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed.
Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Typically responds within 24 hours
✓
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.