answersLogoWhite

0


Best Answer

There is not "a" greedy algorithm; "greedy algorithm" is a term to describe several algorithms that have some things in common. The general idea is that at each step, you look for what seems to be, "locally", the best solution. For example, in a shortest-distance problem, look for a step that takes you closer to the destination. This may, or may not, lead to the best solution overall.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How does the Greedy Algorithm work?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is greedy algorithm and its sample programs?

A greedy algorithm will return as many results as possible. It depends on the algorithm what that means.An example would be in regular expressions. The regexp "/(a.+b)/" searches for a string that starts with "a" and ends with "b". So in the string "There's a bunny in the basket" a greedy algorithm would find "a bunny in the b", while a non-greedy search would find "a b".


What are the difference between greedy algorithm and dynamic programing?

A greedy algorithm is similar to a dynamic programming algorithm, but the difference is that solutions to the subproblems do not have to be known at each stage; instead a "greedy" choice can be made of what looks best for the moment.


Difference between greedy algorithm and dynamic programming?

the basic difference between them is that in greedy algorithm only one decision sequence is ever generated. where as in dynamic programming many decision sequences are generated.


Which one is better kruhskal's algorithm or prim's algorithm?

Both algorithms have the same efficiency and both are based on the same greedy approach. But Kruskal's algorithm is much easier to implement.


What is Dijkstra's algorithm?

Dijkstra's algorithm is used by the OSPF and the IS-IS routing protocols. The last three letters in OSPF (SPF) mean "shortest path first", which is an alternative name for Dijkstra's algorithm.


Does greedy algorithm always work?

Greedy algorithms are only guaranteed to produce locally optimal solutions within a given time frame; they cannot be guaranteed to find globally optimal solutions. However, since the intent is to find a solution that approximates the global solution within a reasonable time frame, in that sense they will always work. If the intent is to find the optimal solution, they will mostly fail.


What is the difference between branch and bound and greedy method?

Branch and bound method is used for optimisation problems. It can prove helpful when greedy approach and dynamic programming fails. Also Branch and Bound method allows backtracking while greedy and dynamic approaches doesnot.However it is a slower method.


What is krushkal algorithm?

Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component). Kruskal's algorithm is an example of a greedy algorithm.


What is the difference between greedy algorithm and Divide and Conquer?

greedy method does not give best solution always.but divide and conquer gives the best optimal solution only(for example:quick sort is the best sort).greedy method gives feasible solutions,they need not be optimal at all.divide and conquer and dynamic programming are techniques.


Advantages of the backtracking algorithm?

Backtracking algorithmn finds minimal path among the all.The main advantage of back tracking algorithmn as compare with greedy is to find minimal distance.In greedy ,it does.t know the optimal solution.It is used in Google earth.


What do you mean by analysis of algorithm?

it is a processor of the work


How do you make a sentence with greedy?

The mongrel's greedy hunger caused him to make short work of the food in the dog bowl.