Visualize & Master
Algorithms & Data Structures
Explore classic & modern sorting algorithms, efficient searching techniques, and interactive data structure visualizations — all with real-time step-by-step animation, comparisons, swaps, and Big-O metrics.
Activity Selection
Select an algorithm and press Play to watch the greedy choices unfold.
Greedy Algorithms Algorithm Catalog
3 algorithms in this category. Click any card for detailed analysis.
Activity Selection
UnstableActivity Selection picks the maximum number of non-overlapping activities given start and end times. The greedy strategy — always choose the activity that finishes earliest — is provably optimal.
Fractional Knapsack
UnstableFractional Knapsack allows taking fractions of items, so the greedy rule — sort by value/weight ratio and take the best first — achieves the optimal value. Unlike 0/1 Knapsack, greedy is optimal here.
Huffman Coding
UnstableHuffman Coding builds a prefix-free binary code for a set of symbols, assigning shorter codes to more frequent symbols. Repeatedly merging the two least-frequent nodes into a tree yields the minimum expected code length.
Complexity & Performance Tradeoffs
Side-by-side comparison of Big-O time and space complexity characteristics across greedy algorithms.
| Algorithm | Best Time | Average Time | Worst Time | Space Complexity | Stability |
|---|---|---|---|---|---|
| Activity Selection | O(n log n) | O(n log n) | O(n log n) | O(n) | Unstable |
| Fractional Knapsack | O(n log n) | O(n log n) | O(n log n) | O(n) | Unstable |
| Huffman Coding | O(n log n) | O(n log n) | O(n log n) | O(n) | Unstable |