andrew_beck
andrew_beck 17h ago โ€ข 0 views

Algorithm Runtime Quiz: Test Your Knowledge of Big O Notation

Hey everyone! ๐Ÿ‘‹ Ready to put your Big O notation knowledge to the test? ๐Ÿค” I've got a quick study guide and a quiz to help you master algorithm runtime. Let's dive in!
๐Ÿ’ป Computer Science & Technology

1 Answers

โœ… Best Answer
User Avatar
jones.jeffrey72 Jan 2, 2026

๐Ÿ“š Quick Study Guide

  • โฑ๏ธ Big O notation describes the upper bound of an algorithm's runtime.
  • ๐Ÿ“ˆ It focuses on how the runtime grows as the input size increases.
  • ๐Ÿฅ‡ Common complexities (fastest to slowest): $O(1) < O(\log n) < O(n) < O(n \log n) < O(n^2) < O(2^n) < O(n!)$
  • ๐Ÿงฎ $O(1)$: Constant time - the runtime is independent of the input size.
  • ๐Ÿ”Ž $O(\log n)$: Logarithmic time - runtime increases logarithmically with input size (e.g., binary search).
  • ๐Ÿšถ $O(n)$: Linear time - runtime increases linearly with input size (e.g., a simple for loop).
  • ๐ŸŒณ $O(n \log n)$: Linearithmic time - often seen in efficient sorting algorithms (e.g., merge sort).
  • ๐Ÿงฑ $O(n^2)$: Quadratic time - runtime increases quadratically with input size (e.g., nested for loops).
  • ๐Ÿ’ฃ $O(2^n)$: Exponential time - runtime doubles with each addition to the input dataset (e.g., brute force).
  • ๐Ÿคฏ $O(n!)$: Factorial time - runtime grows extremely quickly (e.g., generating all permutations of a set).
  • ๐Ÿ’ก When analyzing code, focus on the dominant term (the one that grows the fastest).

๐Ÿงช Practice Quiz

  1. What is the Big O notation for an algorithm that iterates through an array once?
    1. O(1)
    2. O(log n)
    3. O(n)
    4. O(n^2)
  2. Which of the following Big O notations represents the fastest runtime?
    1. O(n)
    2. O(log n)
    3. O(n^2)
    4. O(2^n)
  3. What is the Big O notation for binary search?
    1. O(n)
    2. O(n^2)
    3. O(log n)
    4. O(1)
  4. An algorithm has nested loops, each iterating through the input of size n. What is its Big O notation?
    1. O(n)
    2. O(n log n)
    3. O(n^2)
    4. O(2n)
  5. Which sorting algorithm typically has a time complexity of O(n log n)?
    1. Bubble Sort
    2. Insertion Sort
    3. Merge Sort
    4. Selection Sort
  6. What is the Big O notation for accessing an element in an array by its index?
    1. O(n)
    2. O(log n)
    3. O(1)
    4. O(n log n)
  7. What does Big O notation primarily describe?
    1. The exact runtime of an algorithm
    2. The memory usage of an algorithm
    3. The upper bound of an algorithm's runtime growth
    4. The lower bound of an algorithm's runtime growth
Click to see Answers
  1. C
  2. B
  3. C
  4. C
  5. C
  6. C
  7. C

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! ๐Ÿš€