Lecture 34 CSE 331 Nov 23, 2009. Homework related stuff Graded HW 8+9, solutions to HW 9 the week after Thanksgiving.

Slides:



Advertisements
Similar presentations
Divide-and-conquer: closest pair (Chap.33) Given a set of points, find the closest pair (measured in Euclidean distance) Brute-force method: O(n 2 ). Divide-and-conquer.
Advertisements

Prune-and-Search Method
Lecture 4 Divide and Conquer for Nearest Neighbor Problem
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.
Advanced Algorithm Design and Analysis (Lecture 10) SW5 fall 2004 Simonas Šaltenis E1-215b
Algorithm Design Strategy Divide and Conquer. More examples of Divide and Conquer  Review of Divide & Conquer Concept  More examples  Finding closest.
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 38 CSE 331 Dec 7, The last few days Today: Solutions to HW 9 (end of lecture) Wednesday: Graded HW 9 (?), Sample final, Blog post on the.
Lecture 37 CSE 331 Nov 4, Homework stuff (Last!) HW 10 at the end of the lecture Solutions to HW 9 on Monday Graded HW 9 on.
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 31 CSE 331 Nov 16, Jeff is out of town this week No regular recitation or Jeff’s normal office hours I’ll hold extra Question sessions Mon,
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 38 CSE 331 Dec 3, A new grading proposal Towards your final score in the course MAX ( mid-term as 25%+ finals as 40%, finals as 65%) .
Lecture 4: Divide and Conquer III: Other Applications and Examples Shang-Hua Teng.
See the demo slide on the website. 4 Example 1: Whole Process H G F E D C B A Divide H G F E D C B A Merge G H E F C D A B Merge E F G H A B.
Lecture 24 CSE 331 Oct 30, Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture.
Lecture 36 CSE 331 Dec 2, Graded HW 8 END of the lecture.
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
1 Comments for Assignment 1 Q1 is basic part and is also part of outcome 1. Q2 is for outcome 1. Q3 is for outcome 2. To pass outcome 1, you need to get.
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 39 CSE 331 Dec 9, Announcements Please fill in the online feedback form Sample final has been posted Graded HW 9 on Friday.
Lecture 33 CSE 331 Nov 17, Online office hours Alex will host the office hours.
Lecture 30 CSE 331 Nov 10, Online Office Hours
Lecture 27 CSE 331 Nov 6, Homework related stuff Solutions to HW 7 and HW 8 at the END of the lecture Turn in HW 7.
Lecture 29 CSE 331 Nov 11, To be strictly enforced For the rest of the semester on Fridays SUBMIT your HOMEWORKS by 1:10 PM.
Computational Geometry (35/33) Line Segments and cross-product Segment intersection and Sweep Line Convex Hull and Graham’s Scan, Jarvis’s march Divide-and-Conquer.
File Organization and Processing Week 13 Divide and Conquer.
1 Closest Pair of Points (from “Algorithm Design” by J.Kleinberg and E.Tardos) Closest pair. Given n points in the plane, find a pair with smallest Euclidean.
Lecture 28 CSE 331 Nov 9, Mini project report due WED.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
Lecture 5 Today, how to solve recurrences We learned “guess and proved by induction” We also learned “substitution” method Today, we learn the “master.
1 Announcement Change of Venue for Tutorial Session #T01 and #TA1 from Week 6 to Week 13 (except in Week 8): Section Day Time T01 & TA1 Friday 15:00 -
CSE 331: Review.
CSE 331: Review August 1, Main Steps in Algorithm Design Problem Statement Algorithm Real world problem Problem Definition Precise mathematical.
Lecture 31 CSE 331 Nov 14, 2016.
Lecture 26 CSE 331 Nov 2, 2016.
Lecture 31 CSE 331 Nov 13, 2017.
Lecture 34 CSE 331 Nov 26, 2012.
Punya Biswas Lecture 15 Closest Pair, Multiplication
Lecture 33 CSE 331 Nov 18, 2016.
Lecture 33 CSE 331 Nov 17, 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 32 CSE 331 Nov 14, 2011.
Lecture 29 CSE 331 Nov 8, 2017.
Lecture 28 CSE 331 Nov 7, 2016.
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 31 CSE 331 Nov 14, 2012.
Lecture 31 CSE 331 Nov 12, 2010.
Lecture 10 CSE 331 Sep 21, 2012.
Lecture 36 CSE 331 Nov 28, 2011.
Lecture 36 CSE 331 Nov 30, 2012.
Lecture 30 CSE 331 Nov 12, 2012.
Lecture 15, Winter 2019 Closest Pair, Multiplication
Lecture 31 CSE 331 Nov 11, 2011.
Lecture 30 CSE 331 Nov 9, 2011.
Lecture 32 CSE 331 Nov 12, 2014.
Lecture 15 Closest Pair, Multiplication
Lecture 27 CSE 331 Nov 4, 2016.
Given a list of n  8 integers, what is the runtime bound on the optimal algorithm that sorts the first eight? O(1) O(log n) O(n) O(n log n) O(n2)
Lecture 27 CSE 331 Nov 1, 2013.
Presentation transcript:

Lecture 34 CSE 331 Nov 23, 2009

Homework related stuff Graded HW 8+9, solutions to HW 9 the week after Thanksgiving

Closest pairs of points Input: n 2-D points P = {p 1,…,p n }; p i =(x i,y i ) Output: Points p and q that are closest d(p i,p j ) = ( (x i -x j ) 2 +(y i -y j ) 2 ) 1/2

A property of Euclidean distance d(p i,p j ) = ( (x i -x j ) 2 +(y i -y j ) 2 ) 1/2 yiyi xixi xjxj yjyj

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

Recursively find closest pairs Q R

An aside: maintain sorted lists P x and P y are P sorted by x-coord and y-coord Q x, Q y, R x, R y can be computed from P x and P y in O(n) time

An easy case Q R > δ All “crossing” pairs have distance > δ

Life is not so easy though Q R

Euclid to the rescue (?) d(p i,p j ) = ( (x i -x j ) 2 +(y i -y j ) 2 ) 1/2 yiyi xixi xjxj yjyj

Life is not so easy though Q R δ δ > δ> δ > δ

All we have to do now Q R δ δ S Figure if a pair in S has distance < δ

The algorithm so far… Input: n 2-D points P = {p 1,…,p n }; p i =(x i,y i ) Sort P to get P x and P y Q is first half of P x and R is the rest Closest-Pair (P x, P y ) Compute Q x, Q y, R x and R y (q 0,q 1 ) = Closest-Pair (Q x, Q y ) (r 0,r 1 ) = Closest-Pair (R x, R y ) δ = min ( d(q 0,q 1 ), d(r 0,r 1 ) ) S = points (x,y) in P s.t. |x – x*| < δ return Closest-in-box (S, (q 0,q 1 ), (r 0,r 1 )) If n < 4 then find closest point by brute-force Assume can be done in O(n) O(n log n) O(n) O(n log n) + T(n) T(< 4) = c T(n) = 2T(n/2) + cn O(n log n) overall

Today’s agenda Implement Closest-in-box in O(n) time