{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 7 - The Greedy Approach

# Lecture 7 - The Greedy Approach - The Greedy Approach The...

This preview shows pages 1–8. Sign up to view the full content.

The Greedy Approach

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The Greedy Approach Like Dynamic Programming, greedy algorithms are often used to solve optimization problems. In the greedy approach there is no division of the problem into smaller instances. No need for a recursive property The greedy algorithm arrives at the solution by making a sequence of choices: Each choice made looks best in the local current context: locally optimal . Does not take into consideration previous or future choices. By making locally optimal solution the greedy algorithm may fail to produce a globally optimal solution. For a given algorithm we must determine whether the solution is always optimal.
The Greedy Approach: How it Works ? 1. Select largest coin in value : Selection Procedure 2. Is it OK to add coin to selection set ? (does not exceed \$0.83) Feasibility Check 3. Check if total value of selected coins equals value to return. Solution Check Problem : Return change of \$0.83. Set representing the solution to the problem Available coins Selection criteria

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The Greedy Approach and Optimality Problem : Return change of \$0.82. If a solution exist, does the greedy algorithm always return an optimal Solution ? Available coins Set representing the solution to the Pb using Greedy Algo. Optimal Solution A Greedy Algorithm does not guarantee an Optimal solution
A greedy algorithm starts with an empty set and add items to the set in sequence until the set represents a solution to an instance of the problem. Thus, the greedy approach consists of an iteration of the following computations: - Selection procedure - a selection procedure is created to choose the next item to add to a list of locally optimal solutions to subproblems. - Feasibility check - a test is made to see if the current set of choices satisfies some locally optimal criterion. - Solution check - when a complete set is obtained it is checked to verify that it constitutes a solution for the original problem. The Greedy Approach: General Outline

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Minimum Spanning Trees v 1 v 2 v 3 v 4 v 5 2 4 3 3 5 1 6 v 1 v 2 v 3 v 4 v 5 3 5 1 6 v 1 v 2 v 3 v 4 v 5 2 4 3 1 A Spanning Tree A minimum Spanning Tree Undirected Graph An undirected graph is connected if there is a Path between every pair of vertices. A Tree is an acyclic, connected, undirected graph: Exactly one path between every pair of vertices A Spanning Tree for a graph G is a connected subgraph that contains all the vertices in G and is a tree: A set of |V| - 1 edges that connect all vertices in G. A Minimum Spanning Tree for a graph G is a spanning tree for G That has a minimum total weight. An undirected graph G consists of a finite set of vertices V and a set E of pair of vertices in V called edges of G. G is denoted by: G = (V, E)
Greedy Algorithm for MST: Prim’s Algo. -I- Prim’s Algorithm: Start at a vertex v with an empty set of edges F.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern