Title: UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Fall, 2002
1 UMass Lowell Computer Science 91.503 Analysis
of Algorithms Prof. Karen Daniels Fall, 2002
- Lecture 2
- Tuesday, 9/10/02
- Design Patterns for Optimization Problems
- Greedy Algorithms
2Algorithmic Paradigm Context
3 4What is a Greedy Algorithm?
- Solves an optimization problem
- Optimal Substructure
- optimal solution contains in it optimal solutions
to subproblems - Greedy Strategy
- At each decision point, do what looks best
locally - Choice does not depend on evaluating potential
future choices or solving subproblems - Top-down algorithmic structure
- With each step, reduce problem to a smaller
problem - Greedy Choice Property
- locally best globally best
5Examples
- Minimum Spanning Tree
- Dijkstra Shortest Path
- Huffman Codes
- Fractional Knapsack
- Activity Selection
6 7Minimum Spanning Tree
Time O(ElgE) given fast FIND-SET, UNION
Produces minimum weight tree of edges that
includes every vertex.
Time O(ElgV) O(ElgE) slightly faster
with fast priority queue
for Undirected, Connected, Weighted Graph
G(V,E)
source 91.503 textbook Cormen et al.
8 9Single Source Shortest Paths Dijkstras
Algorithm
for (nonnegative) weighted, directed graph G(V,E)
source 91.503 textbook Cormen et al.
10 11Huffman Codes
12 13Fractional Knapsack
50
Value 60 100 120
30
20
10
knapsack
item1
item2
item3
14 15Example Optimization Problem Activity Selection
- Problem Instance
- Set S 1,2,...,n of n activities
- Each activity i has
- start time si
- finish time fi
- Activities i, j are compatible iff
non-overlapping - Objective
- select a maximum-sized set of mutually compatible
activities
source 91.503 textbook Cormen, et al.
16source 91.503 textbook Cormen, et al.
17Algorithmic Progression
- Brute-Force
- (board work)
- Dynamic Programming 1
- Exponential number of subproblems
- (board work)
- Dynamic Programming 2
- Quadratic number of subproblems
- (board work)
- Greedy Algorithm
- (board work)
18Greedy Algorithm
source 91.503 textbook Cormen, et al.
- Algorithm
- S presort activities in S by nondecreasing
finish time - and renumber
- GREEDY-ACTIVITY-SELECTOR(S)
- n lengthS
- A 1
- j 1
- for i 2 to n
- do if
- then
- j i
- return A
19Additional Examples
- On course web site under Miscellaneous Docs
- Patriotic Tree
- 404 review handout
- Tree Vertex Cover
- 91.503 midterm
20Greedy Heuristic
- If optimization problem does not have greedy
choice property, greedy approach may still be
useful as a heuristic in bounding the optimal
solution - Example minimization problem
Upper Bound (heuristic)
Solution Values
Optimal (unknown value)
Lower Bound
21New Research in Dynamic Channel Assignment
GLOBECOM 2001, IEEE VT submission
Joint work with Prof. Chandra, graduate students
S. Liu, S.Widhani
- Input
- Number of time periods
- 7 x 7 square cell grid
- Set of channels
- Co-channel interference threshold B
27234 - Demand for each time period
- Output
- For each time period
- Feasible assignment of channels to cells
satisfying - Demand model
- Co-channel interference constraints
- (SignalStrength/Interference) gt B
- Computation time limit
- Minimize number of channels used
- Minimize reassignments across time
Demand
Sample solution for 1 time period
Assignment
5 different channels are used
solution assumes no channel repetition within any
2 x 2 square
22Homework
HW Assigned Due Content
- 1 T 9/3 T 9/10 91.404 review
Chapter 15 -
- 2 T 9/10 T 9/17 Chapter 16
-