{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

geosearch-1up

# geosearch-1up - G e o m e t r i c A lg o r i t h m s...

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

Robert Sedgewick and Kevin Wayne • Copyright © 2006 • http://www.Princeton.EDU/~cos226 Geometric Algorithms Reference: Chapters 26-27, Algorithms in C, 2 nd Edition, Robert Sedgewick

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

View Full Document
2 Geometric search: Overview Types of data. Points, lines, planes, polygons, circles, ... This lecture. Sets of N objects. Geometric problems extend to higher dimensions. Good algorithms also extend to higher dimensions. Curse of dimensionality. Basic problems. Range searching. Nearest neighbor. Finding intersections of geometric objects.
3 7.3 Range Searching

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

View Full Document
4 1D Range Search Extension to symbol-table ADT with comparable keys. Insert key-value pair. Search for key k. How many records have keys between k 1 and k 2 ? Iterate over all records with keys between k 1 and k 2 . Application: database queries. Geometric intuition. Keys are point on a line . How many points in a given interval ? insert B B insert D B D insert A A B D insert I A B D I insert H A B D H I insert F A B D F H I insert P A B D F H I P count G to K 2 search G to K H I
5 1D Range Search Implementations Range search. How many records have keys between k 1 and k 2 ? Ordered array. Slow insert, binary search for k 1 and k 2 to find range. Hash table. No reasonable algorithm (key order lost in hash). BST. In each node x, maintain number of nodes in tree rooted at x. Search for smallest element k 1 and largest element k 2 . log N N log N count insert range ordered array N R + log N hash table 1 N BST log N R + log N nodes examined within interval not touched N = # records R = # records that match

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

View Full Document
6 2D Orthogonal Range Search Extension to symbol-table ADT with 2D keys. Insert a 2D key. Search for a 2D key. Range search: find all keys that lie in a 2D range? Range count: how many keys lie in a 2D range? Applications: networking, circuit design, databases. Geometric interpretation. Keys are point in the plane . Find all points in a given h-v rectangle ?
7 2D Orhtogonal Range Search: Grid Implementation Grid implementation. [Sedgewick 3.18] Divide space into M-by-M grid of squares. Create linked list for each square. Use 2D array to directly access relevant square. Insert: insert (x, y) into corresponding grid square. Range search: examine only those grid squares that could have points in the rectangle. LB RT

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

View Full Document
8 2D Orthogonal Range Search: Grid Implementation Costs Space-time tradeoff. Space: M 2 + N. Time: 1 + N / M 2 per grid cell examined on average. Choose grid square size to tune performance. Too small: wastes space. Too large: too many points per grid square. Rule of thumb: N by N grid. Running time. [if points are evenly distributed] Initialize: O(N). Insert: O(1). Range: O(1) per point in range. LB RT
9 Clustering Grid implementation. Fast, simple solution for well-distributed points.

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

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

{[ snackBarMessage ]}

### Page1 / 37

geosearch-1up - G e o m e t r i c A lg o r i t h m s...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online