# What are the major uses of a greedy algorithm?

1. 96
Simone Smithposted 7 years ago

What are the major uses of a greedy algorithm?

And what, in very simple terms, is a greedy algorithm?

2. 85
LuisEGonzalezposted 7 years ago

Algorithm are step by steps recipes for solving a problem.

A greedy algorithm chooses the minimum number of best words, or best choices at every step to try to solve a problem.

It's more complicated than this but this is as simply as I could put it.

Example: I have 2 coins of 5, two coins of 10 and 5 coins of 1 and I need to make the value of 20.

Regular algorithm may use: 1 coin of 10, 1 coin of 5 and 5 coins of 1 or try a different combination to see which solution is better.

Greedy algorithm will use the simplest and shortest route all of the time = 2 coins of 10

3. STAFF
ezhangposted 7 years ago

As LuisEGonzalez mentioned, an algorithm is the method of deciding the steps to solve a problem.

In a greedy algorithm, you always want to find the best path given your choices, in order to reach your goal. Take for example:

-----------
I want to walk from my house to work. If I were to route my path to work by a greedy algorithm, it would probably be something along the lines of:

At each intersection, cross the street whenever it's a green light (in the direction of my workplace of course).
----------

The method of determining my path outlined above, would be the greedy way, because at each intersection, I am taking the *best option* given my choices (my choices being, the direction to cross the street).

An example of a non-greedy algorithm, may involve taking into account the frequency that the traffic lights change colors in a given direction (and thus, may change the pathing of my route, because I may realize that waiting out a red would be more beneficial in overall).

** Note that the greedy method of solving my problem may not necessarily find the most optimal way of getting to work (ie, shortest time), but it does accomplish my goal (ie, getting to work). A greedy algorithm is not guaranteed to give you optimal solutions, but it is guaranteed to give you *a* solution.

4. 60
powerofknowledge1posted 7 years ago