Chapter 2 closest pair of points, lower bound on sorting, select k. Chapter 3 intro to graphs (1).p

# Chapter 2 closest pair of points, lower bound on sorting, select k. Chapter 3 intro to graphs (1).p

• 28

This preview shows pages 1–10. Sign up to view the full content.

Closest Pair of Points in the Plane page 1039 in CLRS traffic-control systems. mechanical parts verification integrated circuits verification

This preview has intentionally blurred sections. Sign up to view the full version.

Classic Problem from Geometry! P = { p 1 , p 2 , , p n } p i = ( x i , y i ) d ( p i , p j ) = ( x i x j ) 2 + ( y i y j ) 2 Find p i , p j P that minimizes d ( p i , p j ) Divide and Conquer!
Finding the closest pair of points O ( n 2 )? P set of n 2 points p 1 , p 2 P , p 1 = ( x 1 , y 1 ), p 2 = ( x 1 , y 2 ) and the distance is ( x 1 x 2 ) 2 + ( y 1 y 2 ) 2

This preview has intentionally blurred sections. Sign up to view the full version.

Divide and Conquer! Q set of n 2 points R set of n 2 points δ distance δ distance
CLOSEST_PAIR_REC(P x, P y ) if |P x | 3 solve and return__________ CONSTRUCT Q x, Q y and R x, R y (q 1 ,q 2 ) = CLOSEST_PAIR_REC(Q x, Q y ) (r 1 , r 2 ) = CLOSEST_PAIR_REC(R x, R y ) = min{ d(q 1 , q 2 ), d(r 1 , r 2 ) } = max x-coordinate in Q x CONSTRUCT S y =(s 1 , s 2 , …, s m ) where s i = (x i, y i ) P and |x i - | for each s i S y , for j = 1 to 7 if d( s i , s i+j ) < (s 1, s 2 ) = ( s i , s i+j ) = d(s 1, s 2 ) return __________ δ x x δ δ δ Q set of n 2 points R set of n 2 points δ distance δ distance s1 s5 s3 s6 s7 s2 s3 s4 δ x

This preview has intentionally blurred sections. Sign up to view the full version.

T '( n ) = 2 T ( n / 2) + O ( n log n ) T ( n ) = 2 T ( n / 2) + O ( n ) if n > 3 O (1) if n 3 T ( n ) = O ( n log n ) T '( n ) = O ( n log 2 n ) Closest Pair Of Points Running time?
Lower Bound on ANY comparison based sorting algorithm

This preview has intentionally blurred sections. Sign up to view the full version.

Weiss, Mark A. (2013-06-11). Data Structures and Algorithm Analysis in C++ (4th Edition) (Page 324). Pearson HE, Inc.. Kindle Edition. Decision Tree for sorting 3 items
(Worst case lower bound for sorting using comparisons) There are n! ways n items can be arranged. Any Algorithm that sorts by using comparisons between elements uses at least cn log(n) comparisons for some input. After 0 comparisons all n! possible ways to order the items are possible. After 1 comparison, the set of possible orders is divided into two groups: the passed the test group and the didn’t pass the test group.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern