What are the major uses of a greedy algorithm?
And what, in very simple terms, is a greedy algorithm?
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
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.
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.
Copyright © 2018 HubPages Inc. and respective owners. Other product and company names shown may be trademarks of their respective owners. HubPages® is a registered Service Mark of HubPages, Inc. HubPages and Hubbers (authors) may earn revenue on this page based on affiliate relationships and advertisements with partners including Amazon, Google, and others.
|HubPages Device ID||This is used to identify particular browsers or devices when the access the service, and is used for security reasons.|
|Login||This is necessary to sign in to the HubPages Service.|
|HubPages Traffic Pixel||This is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.|
|Remarketing Pixels||We may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.|
|Conversion Tracking Pixels||We may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.|