Midterm 2 Review - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Midterm 2 Review

Description:

Unknown: Bin packing (list, num, size) Known: Partition (list) Reduction: Add all items sum ... Complete. Dynamic Programming Solution. Case 2 -- packing a bin ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 13
Provided by: chrisc89
Category:
Tags: list | midterm | packing | review

less

Transcript and Presenter's Notes

Title: Midterm 2 Review


1
Midterm 2 Review
  • Chris Coakley

2
Topics
  • Recurrence Relations
  • Dynamic Programming
  • NP-Complete

3
Recurrence Relations
  • Anything from lecture -- know it
  • Master Method -- Still might apply
  • T(n) T(n-2) O(nk)
  • T(n) 2T(n/2 - 1) O(n)

4
Dynamic Programming
  • Matrix Multiply -- almost guaranteed
  • Something analogous to problem 4 on HW 2
  • Not likely to be like problem 7 on HW 2
  • Rule of thumb An O(nk) time takes O(n(k-1))
    space when dynamic programming

5
Dynamic Programming
  • If T(n) O(nk), k gt 2
  • Try sorting first
  • Assume you need n(k-1) space
  • Solution for 1st element
  • Solution for 2 elements (all cases)
  • ???
  • Profit!

6
Dynamic Programming
  • Harder case Packed schedules or bins
  • Go ahead and sort
  • Start with size 1
  • Find optimal solution for first element
  • Add next element
  • Increment size and repeat
  • Not as likely to be on exam

7
NP-Complete
  • No reductions(!?)
  • Should be restricted to lecture notes
  • Cooks Theorem -- SAT is NP-Complete
  • Examples
  • 3SAT
  • MAX independent set
  • Subset Sum
  • Partition

8
NP Complete
  • More Examples
  • Vertex Cover
  • Knapsack
  • Bin Packing
  • Hamiltonian Cycle
  • TSP

9
NP Complete
  • Reduction
  • Transform every instance of Known to Unknown in
    Polynomial Time
  • Unknown is NP-Hard (is it NP-Complete?)

10
Bad Reduction
  • Unknown into Known
  • Is 2SAT NP Complete?
  • Reduce to 3SAT
  • For each clause, add ( V x)
  • At the end, add (!x V !x V !x)
  • Call 3SAT( new_problem )
  • 2SAT is NP-Hard?

11
Good Reduction
  • Unknown Bin packing (list, num, size)
  • Known Partition (list)
  • Reduction
  • Add all items ? sum
  • Bin_Packing(list, 2, sum/2)

12
Knapsack DP
  • Its NP-Complete
  • Dynamic Programming Solution
  • Case 2 -- packing a bin
Write a Comment
User Comments (0)
About PowerShow.com