Browse

Big-O Time Complexity of Common Operations & Algorithms

Test your knowledge of the time complexity of common data structure operations and classic algorithms.

Code35 items4 levelsDifficulty 3/5
Start training →

Free · no signup · works on any device

Levels

Start easy — harder levels unlock as you improve, or jump ahead anytime.

1
Basics
6 items
2
Sorting & Searching
9 items
3
Data Structures
10 items
4
Advanced
10 items

All 35 cards

Accessing an element by index in an array
O(1)
Linear search through an unsorted array
O(n)
Binary search on a sorted array
O(log n)
Iterating through all elements of an array once
O(n)
Nested loop comparing every pair of n elements
O(n^2)
Appending to the end of a dynamic array (amortized)
O(1)
Bubble sort (worst case)
O(n^2)
Insertion sort (worst case)
O(n^2)
Selection sort (all cases)
O(n^2)
Merge sort (worst case)
O(n log n)
Quicksort (average case)
O(n log n)
Quicksort (worst case)
O(n^2)
Heap sort (worst case)
O(n log n)
Counting sort
O(n + k)
Best possible worst-case for a comparison-based sort
O(n log n)
Hash table lookup (average case)
O(1)
Hash table lookup (worst case)
O(n)
Insertion at the head of a singly linked list
O(1)
Searching for a value in a singly linked list
O(n)
Push or pop on a stack
O(1)
Enqueue or dequeue on a queue
O(1)
Search in a balanced binary search tree
O(log n)
Search in an unbalanced (degenerate) binary search tree
O(n)
Insert or extract-min on a binary heap
O(log n)
Peek at the minimum of a binary min-heap
O(1)
Building a heap from an unsorted array (heapify)
O(n)
Breadth-first or depth-first search of a graph
O(V + E)
Dijkstra's algorithm with a binary heap
O((V + E) log V)
Floyd-Warshall all-pairs shortest paths
O(V^3)
Naive recursive Fibonacci
O(2^n)
Generating all permutations of n elements
O(n!)
Generating all subsets of a set of n elements
O(2^n)
Naive (brute-force) traveling salesman problem
O(n!)
Matrix multiplication (standard naive algorithm)
O(n^3)
Kruskal's algorithm for minimum spanning tree
O(E log E)

Keep going

Data Structures: Use & Time Complexity

Test your knowledge of common data structures, their typical uses, and the Big-O time complexity of their core operations.

Code34 items

Gang of Four Design Patterns: What They Solve

Match each problem to the classic Gang of Four design pattern that solves it.

Code23 items

Common Network Ports and Their Services

Learn which service runs on each well-known TCP/UDP port number.

Code40 items

CSS Properties and What They Control

Learn the most common CSS properties and the styling each one controls.

Code36 items