Questions: Big-O Notation and Complexity Analysis

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A function has an outer loop that runs n times. Inside it is a second loop that runs log(n) times, doing constant work per iteration. What is the Big-O complexity?

AO(n)
BO(n log n)
CO(n²)
DO(log n)
Question 2 Multiple Choice

Algorithm A is O(n) but performs 1,000 basic operations per element. Algorithm B is O(n log n) but performs 2 operations per element. For n = 100, which algorithm runs faster?

AAlgorithm A, because O(n) is asymptotically superior to O(n log n)
BAlgorithm B, because O(n log n) algorithms always have smaller constants
CAlgorithm B, because 100 × log₂(100) × 2 ≈ 1,328 operations vs. 100 × 1,000 = 100,000
DThey are equivalent for n = 100 since both are polynomial
Question 3 True / False

Two algorithms with the same Big-O complexity usually have the same real-world runtime for any given input size.

TTrue
FFalse
Question 4 True / False

Big-O notation describes the worst-case upper bound on an algorithm's growth rate, ignoring constant factors and lower-order terms.

TTrue
FFalse
Question 5 Short Answer

An O(n²) sorting algorithm and an O(n log n) sorting algorithm both solve the same problem. Describe when you might still prefer the O(n²) algorithm, and when you would never use it.

Think about your answer, then reveal below.