CS: Big-O Notation and Algorithm Efficiency
Comparing how algorithms grow as input size increases
Comparing how algorithms grow as input size increases
CS - Grade 9-12
- 1
An algorithm checks each item in a list of n items exactly once. What is its time complexity in Big-O notation? Explain your answer.
- 2
An algorithm prints the first item in a list, no matter how many items are in the list. What is its time complexity in Big-O notation? Explain your answer.
- 3
A program uses two nested loops. The outer loop runs n times, and for each outer loop step, the inner loop also runs n times. What is the time complexity? Explain how you know.
- 4
A binary search algorithm repeatedly cuts a sorted list in half until it finds the target value or runs out of values. What is the time complexity of binary search? Explain why.
- 5
Put these Big-O growth rates in order from fastest growing to slowest growing as n becomes very large: O(n), O(1), O(n^2), O(log n).
- 6
A sorting algorithm takes about n^2 steps in the worst case. If the input size doubles from n to 2n, about how many times more steps will it take? Explain your answer.
- 7
A loop runs from i = 1 to i = n. Inside the loop, the program performs 10 simple operations. What is the time complexity? Explain why the number 10 does not change the Big-O classification.
- 8
Consider this step count for an algorithm: 5n^2 + 20n + 100. What is the Big-O time complexity? Explain which term matters most.
- 9
A program compares every pair of students in a class of n students to see if any two have the same birthday. What is the likely Big-O time complexity if it checks all pairs directly? Explain your answer.
- 10
Two algorithms solve the same problem. Algorithm A is O(n), and Algorithm B is O(n^2). Which algorithm is usually more efficient for very large inputs? Explain your answer.
- 11
An algorithm first loops through n items once, then later uses a separate nested loop that runs n times inside another n-time loop. What is the overall time complexity? Explain your reasoning.
- 12
A student says, "An O(log n) algorithm is always faster than an O(n) algorithm." Explain why this statement is not always true, but why O(log n) is still considered more efficient for large inputs.
Related Cheat Sheets
More CS Worksheets
CS: Algorithms and Flowcharts
Grade 6-8 · 12 problems
CS: Arrays and Lists
Grade 9-12 · 12 problems
CS: Binary Numbers and Number Systems
Grade 6-8 · 12 problems
CS: Boolean Logic and Logic Gates
Grade 6-8 · 12 problems
More Grade 9-12 Worksheets
Linear Equations
Math · 8 problems
Cell Biology
Biology · 8 problems
Reading Comprehension
Language Arts · 8 problems
Historical Thinking & Evidence
Social Studies · 8 problems