Intro to Computer Algorithms Lecture 18 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Intro to Computer Algorithms Lecture 18

Description:

Consider any well-formed substructure s of an optimal structure S. Then s is optimal itself. ... of well-formed substructures into optimal superstructures ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 18
Provided by: pgb8
Category:

less

Transcript and Presenter's Notes

Title: Intro to Computer Algorithms Lecture 18


1
Intro to Computer Algorithms Lecture 18
  • Phillip G. Bradford
  • Computer Science
  • University of Alabama

2
Announcements
  • Advisory Boards Industrial Talk Series
  • http//www.cs.ua.edu/9IndustrialSeries.shtm
  • 2-Dec Mike Thomas, CIO, Gulf States Paper
  • Next Research Colloquia
  • Prof. Nael Abu-Ghazaleh
  • 10-Nov _at_ 1100am
  • Active Routing in Mobile Ad Hoc Networks

3
Computer Security Research Group
  • Meets every Friday from 1100 to 1200
  • In 112 Houser
  • Computer Security, etc.
  • Email me to be on the mailing list!

4
CS Story Time
  • Prof. Jones research group
  • See http//cs.ua.edu/StoryHourSlide.pdf

5
Next Midterm
  • Tuesday before Thanksgiving !
  • 25-November

6
Outline
  • Complete Dynamic Programming
  • Principle of Optimality
  • Start the Greedy Design Paradigm

7
Dynamic Programming
  • Principle of optimality
  • Consider any well-formed substructure s of an
    optimal structure S
  • Then s is optimal itself.
  • This allows the combination of well-formed
    substructures into optimal superstructures

8
Knapsack Problem
  • Section 3.4 from the book

9
Knapsack Problem
  • Suppose the knapsacks capacity is
  • W10
  • What subsets can we choose within the knapsacks
    capacity while maximizing the subsets value?
  • Note 3,4 is optimal
  • Does not include item 1 (of the highest value)

10
Apparent worst-case?
  • Try all subsets!
  • Can we find a better algorithm?
  • It is not clear!

11
Other than exhaustive search?
  • Dynamic programming
  • Vi,j is the optimal solution for
  • w1,,wi (having values v1,,vi)
  • And capacity j W gt j gt 1.
  • Want to find Vn,W
  • Suppose W is a base-10 integer, then how large is
    this table???

12
DP Recurrence for Knapsack
  • Can we fit the ith item?
  • No, then optimal solution is Vi-1,j
  • Yes, then optimal solution
  • Includes ith item vi Vi-1,j-wi
  • Does not include the ith item Vi-1,j
  • If j-wi gt 0
  • Vi,j ? max Vi-1,j, vi Vi-1,j-wi

13
DP Recurrence for Knapsack
  • Base Cases
  • V0,j 0
  • No items in knapsack (with j capacity) has no
    value
  • Vi,0 0
  • Zero capacity, putting items 1,,i does no good

14
Computing this DP Recurrence
Capacity
0,
1,
j-wi
W
0
0
0
0
0
1
0
Value
n
0
15
The Greedy Paradigm
  • Greedy Principle
  • Start with an (optimal) solution and adding
    locally optimal structure eventually gives a
    globally optimal solution

16
The Greedy Paradigm
  • Change Making Problem
  • Not necessarily optimal
  • d1gtd2gt gt dn
  • Give back correct change
  • Greedy Method
  • Start with largest denomination
  • Exhaust it,
  • On to next smaller denomination

17
Prims Algorithm
  • Spanning Tree of an undirected graph
  • Acyclic subgraph containing all nodes
  • Minimum weight spanning tree
  • Weighted edges
  • Among the least cost spanning trees
  • The algorithm
  • The inductive Proof of optimality
Write a Comment
User Comments (0)
About PowerShow.com