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

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

View Full Document Right Arrow Icon
Closest Pair of Points in the Plane page 1039 in CLRS traffic-control systems. mechanical parts verification integrated circuits verification
Image of page 1

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

View Full Document Right Arrow Icon
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!
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
Divide and Conquer! Q set of n 2 points R set of n 2 points δ distance δ distance
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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?
Image of page 6
Lower Bound on ANY comparison based sorting algorithm
Image of page 7

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

View Full Document Right Arrow Icon
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
Image of page 8
(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.
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern