Big O Complexity Quiz

Read each code snippet and identify its time and space complexity. Select your answers and check to see if you're right. Work through all 30 examples to master complexity analysis.

Progress
1 / 30
Score
0 / 0 checked
#1

Linear Search

Loops
def find_element(arr, target):
    for x in arr:
        if x == target:
            return True
    return False

Big O Quick Reference

ComplexityNamen=10Example
O(1)Constant1Hash map lookup, array index
O(log n)Logarithmic3Binary search, heap ops
O(n)Linear10Single loop, linear scan
O(n log n)Linearithmic33Merge sort, heap sort
O(n²)Quadratic100Nested loops, bubble sort
O(n³)Cubic1,000Triple nested loops, naive matrix mult
O(2ⁿ)Exponential1,024Naive fibonacci, power set
O(n!)Factorial3,628,800All permutations, TSP brute force