Leave your Comments

Text from page-1

GREEDY TECHNIQUE
Definition:
Greedy technique is a general algorithm design strategy, built on following elements:
• configurations: different choices, values to find
• objective function: some configurations to be either maximized or minimized
The method:
•
•
•
•
•
•
Applicable to optimization problems ONLY
Constructs a solution through a sequence of steps
Each step expands a partially constructed solution so far, until a complete solution
to the problem is reached.
On each step, the choice made must be
Feasible: it has to satisfy the problem’s constraints
Locally optimal: it has to be the best local choice among all feasible choices
available on that step
Irrevocable: Once made, it cannot be changed on subsequent steps of the
algorithm
NOTE:
• Greedy method works best when applied to problems with the greedy-choice
property
• A globally-optimal solution can always be found by a series of local
improvements from a starting configuration.
Greedy method vs. Dynamic programming method:
•
•
•
LIKE dynamic programming, greedy method solves optimization problems.
LIKE dynamic programming, greedy method problems exhibit optimal
substructure
UNLIKE dynamic programming, greedy method problems exhibit the greedy
choice property -avoids back-tracing.
Applications of the Greedy Strategy:
•
•
Optimal solutions:
Change making
Minimum Spanning Tree (MST)
Single-source shortest paths
Huffman codes
Approximations:
Traveling Salesman Problem (TSP)
Fractional Knapsack problem
1

Text from page-2

Spanning Tree
Definition:
Spanning tree is a connected acyclic sub-graph (tree) of the given graph (G) that includes
all of G’s vertices
Example: Consider the following graph
1
b
a
2
5
c
d
3
The spanning trees for the above graph are as follows:
1
1
b
b
a
a
2
5
d
5
3
c
d
c
Weight (T2) = 8
Weight (T1) = 9
1
a
b
2
d
c
3
Weight (T3) = 6
Minimum Spanning Tree (MST)
Definition:
MST of a weighted, connected graph G is defined as: A spanning tree of G with
minimum total weight.
Example: Consider the example of spanning tree:
For the given graph there are three possible spanning trees. Among them the spanning
tree with the minimum weight 6 is the MST for the given graph
Question: Why can’t we use BRUTE FORCE method in constructing MST ?
Answer: If we use Brute force method• Exhaustive search approach has to be applied.
• Two serious obstacles faced:
1. The number of spanning trees grows exponentially with graph size.
2. Generating all spanning trees for the given graph is not easy.
2