Introduction to Greedy Algorithms
Learn what greedy algorithms are and how they can be used to solve different problems.
Greedy algorithms
In this chapter, we’ll learn about seemingly naive yet powerful greedy algorithms. After learning the key idea behind the greedy algorithms, some students feel that they represent the algorithmic Swiss Army knife that can be applied to solve nearly all programming challenges in this course. Be warned: since this intuitive idea rarely works in practice, we have to prove that our greedy algorithm produces an optimal solution!
We’ll be solving the following problems with greedy algorithms:
Money change
Compute the minimum number of coins needed to change the given value into coins with denominations , , and .
Input: An integer .
Output: The minimum number of coins with denominations , , and that changes .
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.