Lecture 32 CSE 331 Nov 12, 2014.

Slides:



Advertisements
Similar presentations
Lecture 30 CSE 331 Nov 8, HW 7 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.
Advertisements

Lecture 30 CSE 331 Nov 13, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
Lecture 28 CSE 331 Nov 9, Flu and HW 6 Graded HW 6 at the END of the lecture If you have the flu, please stay home Contact me BEFORE you miss a.
Lecture 32 CSE 331 Nov 18, HW 8 solutions Friday.
Lecture 34 CSE 331 Nov 19, HW 9 due today Q1 in one pile and Q 2+3 in another I will not take any HW after 1:15pm.
Lecture 33 CSE 331 Nov 20, Homeworks Submit HW 9 by 1:10PM HW 8 solutions at the end of the lecture.
Lecture 36 CSE 331 Dec 2, Graded HW 8 END of the lecture.
Lecture 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
Lecture 34 CSE 331 Nov 23, Homework related stuff Graded HW 8+9, solutions to HW 9 the week after Thanksgiving.
Lecture 37 CSE 331 Dec 1, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
Lecture 24 CSE 331 Oct 27, Online office hours tonight 9:00pm.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
Lecture 20 CSE 331 Oct 21, Algorithm for Interval Scheduling R: set of requests Set A to be the empty set While R is not empty Choose i in R with.
Lecture 30 CSE 331 Nov 10, Online Office Hours
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
Lecture 18 CSE 331 Oct 12, HW 5 due today Q1, Q2 and Q3 in different piles I will not take any HW after 1:15pm.
Lecture 18 CSE 331 Oct 6, Group/Algo registration deadline BOTH DUE WED by 11:59pm!
Lecture 33 CSE 331 Nov 20, HW 8 due today Place Q1, Q2 and Q3 in separate piles I will not accept HWs after 1:15pm Submit your HWs to the side of.
Lecture 32 CSE 331 Nov 16, 2016.
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 26 CSE 331 Nov 2, 2016.
Lecture 16 CSE 331 Oct 5, 2016.
Lecture 17 CSE 331 Oct 3, 2014.
Lecture 31 CSE 331 Nov 13, 2017.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 34 CSE 331 Nov 26, 2012.
Lecture 36 CSE 331 Nov 29, 2017.
Lecture 36 CSE 331 Nov 30, 2016.
Lecture 20 CSE 331 Oct 14, 2016.
Lecture 17 CSE 331 Oct 7, 2016.
Lecture 33 CSE 331 Nov 18, 2016.
Lecture 33 CSE 331 Nov 17, 2017.
Lecture 37 CSE 331 Dec 1, 2017.
Lecture 30 CSE 331 Nov 11, 2016.
Lecture 33 CSE 331 Nov 19, 2012.
Lecture 26 CSE 331 Nov 1, 2017.
Lecture 27 CSE 331 Nov 3, 2017.
Lecture 19 CSE 331 Oct 12, 2016.
Lecture 16 CSE 331 Oct 4, 2017.
Lecture 32 CSE 331 Nov 14, 2011.
Lecture 29 CSE 331 Nov 8, 2017.
Lecture 28 CSE 331 Nov 7, 2016.
Lecture 18 CSE 331 Oct 12, 2011.
Lecture 19 CSE 331 Oct 8, 2014.
Lecture 20 CSE 331 Oct 17, 2011.
Lecture 32 CSE 331 Nov 15, 2017.
Lecture 33 CSE 331 Nov 14, 2014.
Lecture 30 CSE 331 Nov 10, 2017.
Lecture 27 CSE 331 Oct 31, 2014.
Lecture 33 CSE 331 Nov 15, 2013.
Lecture 34 CSE 331 Nov 18, 2011.
Lecture 28 CSE 331 Nov 7, 2012.
Lecture 27 CSE 331 Nov 2, 2010.
Lecture 18 CSE 331 Oct 9, 2017.
Lecture 31 CSE 331 Nov 14, 2012.
Lecture 20 CSE 331 Oct 13, 2017.
Lecture 21 CSE 331 Oct 19, 2011.
Lecture 21 CSE 331 Oct 22, 2012.
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 36 CSE 331 Nov 30, 2012.
Lecture 37 CSE 331 Dec 2, 2016.
Lecture 30 CSE 331 Nov 12, 2012.
Lecture 31 CSE 331 Nov 11, 2011.
Lecture 30 CSE 331 Nov 9, 2011.
Lecture 19 CSE 331 Oct 10, 2016.
Advanced Algorithms Analysis and Design
Lecture 27 CSE 331 Nov 4, 2016.
Lecture 27 CSE 331 Nov 1, 2013.
Lecture 36 CSE 331 Nov 22, 2013.
Presentation transcript:

Lecture 32 CSE 331 Nov 12, 2014

Online OH tonight @8:45pm

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

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

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

An aside: maintain sorted lists Px and Py are P sorted by x-coord and y-coord Qx, Qy, Rx, Ry can be computed from Px and Py in O(n) time

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

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

Euclid to the rescue (?) d(pi,pj) = ( (xi-xj)2+(yi-yj)2)1/2 yj yi xi The distance is larger than the x or y-coord difference

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

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

Assume can be done in O(n) The algorithm so far… O(n log n) + T(n) Input: n 2-D points P = {p1,…,pn}; pi=(xi,yi) Sort P to get Px and Py O(n log n) T(< 4) = c Closest-Pair (Px, Py) T(n) = 2T(n/2) + cn If n < 4 then find closest point by brute-force Q is first half of Px and R is the rest O(n) Compute Qx, Qy, Rx and Ry O(n) (q0,q1) = Closest-Pair (Qx, Qy) O(n log n) overall (r0,r1) = Closest-Pair (Rx, Ry) O(n) δ = min ( d(q0,q1), d(r0,r1) ) O(n) S = points (x,y) in P s.t. |x – x*| < δ return Closest-in-box (S, (q0,q1), (r0,r1)) Assume can be done in O(n)

Rest of today’s agenda Implement Closest-in-box in O(n) time

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

Greedy Algorithms Natural algorithms Reduced exponential running time to polynomial

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

A new algorithmic technique Dynamic Programming

Dynamic programming vs. Divide & Conquer

Same same because Both design recursive algorithms

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

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

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

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