Greedy Algorithm: Annu Malik, Anju Sharma, Mr. Vinod Saroha (Guide)
Greedy Algorithm: Annu Malik, Anju Sharma, Mr. Vinod Saroha (Guide)
Greedy Algorithm: Annu Malik, Anju Sharma, Mr. Vinod Saroha (Guide)
ISSN 2250-3153
Greedy Algorithm
Annu Malik, Anju Sharma, Mr. Vinod Saroha (Guide)
Abstract- This paper presents a survey on Greedy Algorithm. options within a search, or branch and bound algorithm. There
This discussion is centered on overview of Activity Selection are a few variations to the greedy algorithm:
Problem and Task Scheduling Problem . A greedy algorithm is Pure greedy algorithms
an algorithm that follows the problem solving heuristic of Orthogonal greedy algorithms
making the locally optimal choice at each stage with the hope of Relaxed greedy algorithms
finding a global optimum. In many problems, a greedy strategy
does not in general produce an optimal solution, but nonetheless
a greedy heuristic may yield locally optimal solutions that III. AN ACTIVITY SELECTION PROBLEM
approximate a global optimal solution in a reasonable
time.Greedy algorithms determine the minimum number of coins Our first example is the problem of scheduling a resource
to give while making change. These are the steps a human would among several competing activities. We shall find that the greedy
take to emulate a greedy algorithm to represent 36 cents using algorithm provides a well-designed and simple method for
only coins with values {1, 5, 10, 20}. The coin of the highest selecting a maximum-size of mutually compatible activities.
value, less than the remaining change owed, is the local Suppose S={1,2,.....,n} is the set of proposed activities. The
optimum. (Note that in general the change-making problem activities share a resource, which can be used by only one
requires dynamic programming or integer programming to find activity at a time e.g., a Tennis Court, a Lecture Hall etc. Each
an optimal solution; However, most currency systems, including activity i has a start time si and a finish time fi, where si≤ fi. If
the Euro and US Dollar, are special cases where the greedy selected, activity i takes place during the half-open time
strategy does find an optimum solution.) interval[si, fi}. Activities i and j are compatible if the intervals [sj,
fj) and [si, fi) do not overlap (i.e, I and j are compatible if s i ≥ fj
Index Terms- Greedy, scheduling, activity, optimal, algorithm or sj ≥ fj ).
etc The activity selection problem selects the maximum-size set
of mutually compatible activities.
In this strategy we first select the activity with minimum
duration (fi-si) and schedule it. Then, we skip all activities that
I. INTRODUCTION
are not compatible to this one, which means we have to select
1) Greedy Choice Property: A globally optimal solution The running time of an algorithm GREEDY-ACTIVITY-
can be arrived at by making a locally optimal solution. SELECTOR is Ө(nlogn), as sorting can be done in О(nlogn).
In other words, an optimal solution can be obtained by There are О(1) operations per activity, thus total time is
making “greedy” choices.
2) Optimal Substructure: Optimal solutions contains О(nlogn) + n.О(1) = О(nlogn)
optimal sub solutions. In other words, solutions to sub
problems of an optimal solution are optimal. The pseudo code of GREEDY-ACTIVITY-SELECTOR is
as follows:
www.ijsrp.org
International Journal of Scientific and Research Publications, Volume 3, Issue 8, August 2013 2
ISSN 2250-3153
Activity A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
Start 1 3 2 4 8 7 9 11 9 12
Finish 3 4 5 7 9 10 11 12 13 14
www.ijsrp.org
International Journal of Scientific and Research Publications, Volume 3, Issue 8, August 2013 3
ISSN 2250-3153
A10
A8
A9
A7
A
C A5
T
I
V
I A6
T
Y
A4
A2
A3
A1
1 2 3 4 5 6 7 8 9 10 11 12 13 14
TIME
www.ijsrp.org
International Journal of Scientific and Research Publications, Volume 3, Issue 8, August 2013 4
ISSN 2250-3153
www.ijsrp.org
International Journal of Scientific and Research Publications, Volume 3, Issue 8, August 2013 5
ISSN 2250-3153
V. APPLICATIONS but the hidden part may backfire on you when you least expect.
Greedy algorithms mostly (but not always) fail to find the While there are some standardized problems, most of the
globally optimal solution, because they usually do not operate problems solvable by this method call for heuristics. There is no
exhaustively on all the data. They can make commitments to general template on how to apply the greedy method to a given
certain choices too early which prevent them from finding the problem, however the problem specification might give you a
best overall solution later. For example, all known greedy good insight. In some cases there are a lot of greedy assumptions
coloring algorithms for the graph coloring problem and all other one can make, but only few of them are correct. They can
NP-complete problems do not consistently find optimum provide excellent challenge opportunities.
solutions. Nevertheless, they are useful because they are quick to
think up and often give good approximations to the optimum.
If a greedy algorithm can be proven to yield the global REFERENCES
optimum for a given problem class, it typically becomes the [1] Wikipedia
method of choice because it is faster than other optimization [2] Google
methods like dynamic programming. Examples of such greedy [3] Algorithms Design and Analysis by Udit Agarwal
algorithms are Kruskal's algorithm and Prim's algorithm for
finding minimum spanning trees, Dijkstra's algorithm for finding
single-source shortest paths, and the algorithm for finding AUTHORS
optimum Huffman trees.
First Author – Annu Malik, M.Tech (Persuing), CSE(Network
Security), SES BPSMV Uniersity, Khanpur Kalan, Sonepat,
Haryana and annu1990malik@gmailcom.
VI. CONCLUSION Second Author – Anju Sharma, M.Tech (Persuing),
Greedy algorithms are usually easy to think of, easy to CSE(Network Security), SES BPSMV Uniersity, Khanpur
implement and run fast. Proving their correctness may require Kalan, Sonepat, Haryana and anjusharma264@gmailcom.
rigorous mathematical proofs and is sometimes insidious hard. In Third Author – Mr. Vinod Saroha (Guide), M.Tech(Assistant
addition, greedy algorithms are infamous for being tricky. Professor in CSE and IT Department), SES BPSMV Uniersity,
Missing even a very small detail can be fatal. But when you have Khanpur Kalan, Sonepat, Haryana) and vnd.saroha@gmailcom.
nothing else at your disposal, they may be the only salvation.
With backtracking or dynamic programming you are on a Correspondence Author – Annu Malik,
relatively safe ground. With greedy instead, it is more like annu1990malik@gmail.com, sbit.cse08408@gmail.com),
walking on a mined field. Everything looks fine on the surface, 08813034437.
www.ijsrp.org