Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
courses:cs211:winter2014:journals:emily:entryseven [2014/03/12 00:39] – [Chapter 5.3] hardye | courses:cs211:winter2014:journals:emily:entryseven [2014/03/25 19:10] (current) – [Seventh Entry] hardye | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== Entry Seven ====== |
====== Chapter 5.2 ====== | ====== Chapter 5.2 ====== | ||
Line 91: | Line 91: | ||
**Finding the Closest Pair of Points** | **Finding the Closest Pair of Points** | ||
+ | The Problem: | ||
+ | We are given a plane with a set of n points. Our goal is to find the pair of points that is closest together with a runtime of O(n log n). | ||
+ | |||
+ | **The Algorithm: | ||
+ | |||
+ | We are given the set of points P where each point p< | ||
+ | |||
+ | **(5.10)** If s, s' in S have the property that d(s, s') < z, then s and s' are within 15 positions of each other in the sorted list Sy. | ||
+ | |||
+ | Proof: any two points in the same box are within the distance z*(sqrt2/2) < z which is a contradiction that z is the min distance between any pair in Q or R so each box has only one point in S. | ||
+ | |||
+ | **Analysis: | ||
+ | |||
+ | Proof by induction that the algorithm correctly outputs a closest pair of points in P. The runtime of the algorithm is O(n log n). Sorting the points by their x and y coordinates takes O(n log n) time and the recurrence is T(n) =< 2T(n/2)+cn is O(n log n), so the whole algorithm is bounded by n log n. | ||
+ | |||
+ | This section got really confusing when we were considering the subset S with all of the boxes and the distances. I'm still kind of confused by why the points have to be within 15 positions of each other. Overall it was readability: |