Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Counting Sort Lab
Sorting
Problem shape
Intermediate
4
8
15
16
23
42
Core idea
Count each key, then rebuild output in key order.
Step 1 / 5
Problem shape
Sorting Intermediate
Counting Sort
Welcome to the Counting Sort algorithm lab. Count each key, then rebuild output in key order. Use it when: Use when keys are integers in a small known range. The time complexity is O(n + k), and the space complexity is O(k). The pseudocode is: count every value for value from min to max repeat count[value] times output value As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
O(n + k)
Space
O(k)
Pseudocode
count every value
for value from min to max
repeat count[value] times
output value 1.0x