CS Grade 9-12

CS: Big-O Notation and Algorithm Efficiency

Comparing how algorithms grow as input size increases

View Answer Key
Name:
Date:
Score: / 12

Comparing how algorithms grow as input size increases

CS - Grade 9-12

Instructions: Read each problem carefully. Show your reasoning in the space provided. Use Big-O notation to describe growth rates when asked.
  1. 1
    A list of items is scanned from start to finish, with every item visited once.

    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. 2
    Only the first item in a list is selected while the rest are ignored.

    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. 3
    A full square grid shows work done for every combination of two nested loops.

    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. 4
    Binary search repeatedly halves a sorted list until a small target area remains.

    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. 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. 6
    A square grid with doubled side length shows four times as many cells.

    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. 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. 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. 9
    Every student is connected to every other student, representing all pair comparisons.

    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. 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. 11
    A single pass through a list is followed by a larger nested-loop grid of work.

    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. 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.

LivePhysics™.com CS - Grade 9-12

More CS Worksheets

See all CS worksheets

More Grade 9-12 Worksheets

See all Grade 9-12 worksheets