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

*sort by* **best** latest

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.

You can help the HubPages community highlight top quality content by ranking this answer up or down.

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

You can help the HubPages community highlight top quality content by ranking this answer up or down.

I read about this algorithm when i was pursuing my B.Tech.

Greedy algorithm is used for optimization problems. One of the example of Greedy Algorithm is "Traveling Salesman Problem".

In traveling salesman problem you have to visit the unvisited city nearest to the current city but you cannot repeat your path.

You can help the HubPages community highlight top quality content by ranking this answer up or down.