Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 33 CSE 331 Nov 15, 2013.

Similar presentations


Presentation on theme: "Lecture 33 CSE 331 Nov 15, 2013."— Presentation transcript:

1 Lecture 33 CSE 331 Nov 15, 2013

2 HW 8 due today Place Q1, Q2 and Q3 in separate piles
I will not accept HWs after 1:15pm DO NOT FORGET TO WRITE DOWN YOUR SOURCES

3 Related HW stuff HW 9 has been posted on piazza
Solutions to HW 8 at the END of the lecture Can pick up graded HW 7 from Monday

4 Closest pairs of points
Input: n 2-D points P = {p1,…,pn}; pi=(xi,yi) d(pi,pj) = ( (xi-xj)2+(yi-yj)2)1/2 Output: Points p and q that are closest

5 Dividing up P Q R First n/2 points according to the x-coord

6 Recursively find closest pairs
Q R δ = min (blue, green)

7 An easy case R > δ Q All “crossing” pairs have distance > δ
δ = min (blue, green)

8 Life is not so easy though
Q R δ = min (blue, green)

9 Life is not so easy though
δ Q R > δ > δ > δ δ = min (blue, green)

10 All we have to do now δ R Q S
Figure if a pair in S has distance < δ S δ = min (blue, green)

11 Rest of today’s agenda Prove the Kickass Property Lemma

12 HW 8 due today Place Q1, Q2 and Q3 in separate piles
I will not accept HWs after 1:15pm DO NOT FORGET TO WRITE DOWN YOUR SOURCES

13 Three general techniques
High level view of CSE 331 Problem Statement Problem Definition Three general techniques Algorithm “Implementation” Data Structures Analysis Correctness+Runtime Analysis

14 Greedy Algorithms Natural algorithms
Reduced exponential running time to polynomial

15 Divide and Conquer Recursive algorithmic paradigm
Reduced large polynomial time to smaller polynomial time

16 A new algorithmic technique
Dynamic Programming

17 Dynamic programming vs. Divide & Conquer

18 Same same because Both design recursive algorithms

19 Different because Dynamic programming is smarter about solving recursive sub-problems

20 Using Memory to be smarter
Pow (a,n) // n is even and ≥ 2 return t * t t= Pow(a,n/2) Pow (a,n) // n is even and ≥ 2 return Pow(a,n/2) * Pow(a, n/2) O(n) as we recompute! O(log n) as we compute only once

21 End of Semester blues Can only do one thing at any day: what is the optimal schedule to obtain maximum value? Write up a term paper (30) (3) (2) (5) (10) Party! Exam study 331 HW Project Monday Tuesday Wednesday Thursday Friday

22 Previous Greedy algorithm
Order by end time and pick jobs greedily Greedy value = 5+2+3= 10 Write up a term paper (10) OPT = 30 Party! (2) Exam study (5) 331 HW (3) Project (30) Monday Tuesday Wednesday Thursday Friday

23 Today’s agenda Formal definition of the problem
Start designing a recursive algorithm for the problem


Download ppt "Lecture 33 CSE 331 Nov 15, 2013."

Similar presentations


Ads by Google