This preview shows pages 1–17. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 ,a 2 ); max(a 1 ,a 2 )) a L = a 1 ,, a n/2 a R = a n/2+1 ,, a n return ( c+c L +c R ,a ) (c L , a L ) = MergeSortCount ( a L , n/2 ) (c R , a R ) = MergeSortCount ( a R , n/2 ) (c, a) = MERGECOUNT ( a L ,a R ) Counts #crossinginversions+ MERGE Counts #crossinginversions+ MERGE O(n) O(n) T(2) = c T(n) = 2T(n/2) + cn O(n log n) time O(n log n) time If n = 1 return ( 0 , a 1 ) Rest of todays agenda MERGECOUNT Computing closest pair of points Closest pairs of points Input: n 2D 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 ix j ) 2 +( y iy j ) 2 ) 1/2 Group Talk time O(n 2 ) time algorithm? 1D problem in time O(n log n) ? Sorting to rescue in 2D? Pick pairs of points closest in x coordinate Pick pairs of points closest in y coordinate Choose the better of the two Rest of todays agenda Divide and Conquer based algorithm...
View
Full
Document
This note was uploaded on 12/11/2011 for the course CSE 331 taught by Professor Rudra during the Fall '11 term at SUNY Buffalo.
 Fall '11
 RUDRA

Click to edit the document details