answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

βˆ™ 9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Does greedy algorithm always work
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How does the Greedy Algorithm work?

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.


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.


Is heyristic an algorithm?

A heuristic is not an algorithm, but rather a general rule of thumb. It doesn't always work, but it's fairly decent.


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.


What is the importance of analysis in the design of an algorithm?

There are two main reasons we analyze an algorithm: correctness and efficiency. By far the most important reason to analyze an algorithm is to make sure it will correctly solve your problem. If our algorithm doesn't work, nothing else matters. So we must analyze it to prove that it will always work as expected. We must also look at the efficiency of our algorithm. If it solves our problem, but does so in O(nn) time (or space!), then we should probably look at a redesign.


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.


A sentence with the word greedy in it?

Mark was always very greedy.Being too greedy turns people against you.The greedy king was overthrown by the rebellion.


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.