English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-07-05 22:31:35 · 8 answers · asked by Ravinder R 1 in Computers & Internet Programming & Design

8 answers

A greedy algorithm is any algorithm that follows the problem solving metaheuristic of making the locally optimum choice at each stage with the hope of finding the global optimum.

For example, applying the greedy strategy to the traveling salesman problem yields the following algorithm: "At each stage visit the unvisited city nearest to the current city".

1. A candidate set, from which a solution is created
2. A selection function, which chooses the best candidate to be added to the solution
3. A feasibility function, that is used to determine if a candidate can be used to contribute to a solution
4. An objective function, which assigns a value to a solution, or a partial solution, and
5. A solution function, which will indicate when we have discovered a complete solution

Greedy algorithms produce good solutions on some mathematical problems, but not on others. Most problems for which they work well have two properties:

Greedy Choice Property
We can make whatever choice seems best at the moment and then solve the subproblems that arise later. The choice made by a greedy algorithm may depend on choices made so far but not on future choices or all the solutions to the subproblem. It iteratively makes one greedy choice after another, reducing each given problem into a smaller one. In other words, a greedy algorithm never reconsiders its choices. This is the main difference from dynamic programming, which is exhaustive and is guaranteed to find the solution. After every stage, dynamic programming makes decisions based on all the decisions made in the previous stage, and may reconsider the previous stage's algorithmic path to solution.

Optimal Substructure
A problem exhibits optimal substructure if an optimal solution to the problem contains optimal solutions to the sub-problems.

When greedy-type algorithms fail
For many other problems, greedy algorithms may produce the unique worst possible solutions. One example is the nearest neighbor algorithm mentioned above: for each number of cities there is an assignment of distances between the cities for which the nearest neighbor heuristic produces the unique worst possible tour

Or goto
http://en.wikipedia.org/wiki/Greedy_algorithm

hope this will solve your issues

Cheers:)

2007-07-05 22:38:09 · answer #1 · answered by Neeraj Yadav♥ 6 · 0 0

The "greedy algorithm" is an algorithm that tries to do as much as possible at each step without looking ahaed. The classic example of the greedy algorithm is giving change. It works like this: 1) Give as many of the largest denomination of coin you haven't tried yet. 2) Repeat until no more money is owed. So, to give change for $7.32 using $100 bills, $10 bills, $5 bills, $1 bills, quarters, dimes, nickles, and pennies using greedy, we do this: The largest denomination we haven't tried yet is $100 bills. We can't give any (since $7.32 is less than $100). The largest denomination we haven't tried yet is $10 bills. We can't give any, $7.32 is less than $10. $5 bills, we can give 1, leaving $2.32 to give. $1 bills, we can give 2, leaving $0.32 to give Quarters, we can give 1, leaving $0.07 to give. Dimes, we can give none. Nickels, we can give 1, leaving $0.02 to give. Pennies, we can give 2, leaving $0.00 to give. We are done. So using greedy, we make change for $7.32 as one $5 bill, two $1 bills, a quarter, a nickel, and two pennies. Note that greedy is, in general, not even the best algorithm for making change. For example, if we had 8 cent coins, greedy would make change for $.16 as 1 dime, 1 nickel, and 1 penny, needing 3 coins (try it and see). But two 8 cent coins would do.

2016-05-19 21:17:29 · answer #2 · answered by ? 3 · 0 0

So, what about Greedy Algorithm? Plz be specfic in questions.....

2007-07-05 22:54:53 · answer #3 · answered by Anonymous · 0 0

Simple, usually recursive in nature. Just do it without regard whether the stuff it ends up is of value to your task.

Djikstra's graphing path is such greedy stuff.

2007-07-05 22:41:08 · answer #4 · answered by Andy T 7 · 0 0

Definitely.
http://en.wikipedia.org/wiki/Greedy_algorithm

2007-07-05 22:37:41 · answer #5 · answered by adi 4 · 0 0

Certainly...

2007-07-05 23:45:02 · answer #6 · answered by Essess 2 · 0 0

You mean Heuristics.

2007-07-05 22:34:18 · answer #7 · answered by ★Greed★ 7 · 0 0

Yes it is very simple.

2007-07-05 22:33:57 · answer #8 · answered by Anonymous · 0 0

Are you on a diet then?

2007-07-05 22:36:52 · answer #9 · answered by Anonymous · 0 0

fedest.com, questions and answers