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 Greedy Thinking Lab
Problem Solving
Concept shape
Practice pattern
0
1
2
3
4
5
Definition
A greedy algorithm makes the locally best choice and commits to it.
Step 1 / 5
Concept shape
Problem Solving Practice pattern
Greedy Thinking
Welcome to the Greedy Thinking concept lab. A greedy algorithm makes the locally best choice and commits to it. The must know points are: Must prove local choices lead to global optimum. Sorting often comes first. Not every optimization problem is greedy. The common operations are: sort by rule, choose best next, commit choice. The complexity shape is Often O(n log n) due to sorting. Watch out for these pitfalls: Using greedy without proof. Choosing the wrong sorting rule. Related algorithms include Activity Selection, Merge Intervals.
Concept details
A greedy algorithm makes the locally best choice and commits to it.
Must know
- Must prove local choices lead to global optimum.
- Sorting often comes first.
- Not every optimization problem is greedy.
Complexity
Often O(n log n) due to sorting
1.0x