{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

module07

module07 - Module 7 Dictionaries for Multi-Dimensional Data...

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

Module 7: Dictionaries for Multi-Dimensional Data CS 240 - Data Structures and Data Management Arne Storjohann Based on lecture notes by R. Dorrigiv and D. Roche School of Computer Science, University of Waterloo Fall 2010 Arne Storjohann (CS, UW) CS240 - Module 7 Fall 2010 1 / 21

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

View Full Document
Multi-Dimensional Data Various applications I Attributes of a product (laptop: price, screen size, processor speed, RAM, hard drive, · · · ) I Attributes of an employee (name, age, salary, · · · ) Dictionary for multi-dimensional data A collection of d -dimensional items Each item has d aspects (coordinates): ( x 0 , x 1 , · · · , x d - 1 ) Operations: insert, delete, range-search query (Orthogonal) Range-search query: specify a range (interval) for certain aspects, and find all the items whose aspects fall within given ranges. Example: laptops with screen size between 12 and 14 inches, RAM between 2 and 4 GB, price between 500 and 800 CAD Arne Storjohann (CS, UW) CS240 - Module 7 Fall 2010 2 / 21
Multi-Dimensional Data Each item has d aspects (coordinates): ( x 0 , x 1 , · · · , x d - 1 ) Aspect values ( x i ) are numbers Each item corresponds to a point in d -dimensional space We concentrate on d = 2, i.e., points in Euclidean plane price (CAD) 1100 1300 1400 1500 1600 1700 1800 processor speed (MHz) 600 800 1000 1200 (1200,1000) range-search query ( 1350 x 1550 , 700 y 1100 ) item: ordered pair ( x , y ) R × R Arne Storjohann (CS, UW) CS240 - Module 7 Fall 2010 3 / 21

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

View Full Document
One-Dimensional Range Search First solution : ordered arrays I Running time: O (log n + k ), k : number of reported items I Problem: does not generalize to higher dimensions Second solution : balanced BST (e.g., AVL tree) BST-RangeSearch ( T , k 1 , k 2 ) T : A balanced search tree, k 1 , k 2 : search keys Report keys in T that are in range [ k 1 , k 2 ] 1. if T = nil then return 2. if key ( T ) < k 1 then 3. BST-RangeSearch( T . right , k 1 , k 2 ) 4. if key ( T ) > k 2 then 5. BST-RangeSearch( T . left , k 1 , k 2 ) 6. if k 1 key ( T ) k 2 then 7. BST-RangeSearch( T . left , k 1 , k 2 ) 8. report key ( T ) 9. BST-RangeSearch( T . right , k 1 , k 2 ) Arne Storjohann (CS, UW) CS240 - Module 7 Fall 2010 4 / 21
One-Dimensional Range Search P 1 : path traversed in BST-Search ( T , k 1 ) P 2 : path traversed in BST-Search ( T , k 2 ) Partition nodes of T into three groups: 1 boundary nodes : nodes in P 1 or P 2 2 inside nodes : non-boundary nodes that belong to either (a subtree rooted at a right child of a node of P 1 ) or (a subtree rooted at a left child of a node of P 2 ) 3 outside nodes : non-boundary nodes that belong to either (a subtree rooted at a left child of a node of P 1 ) or (a subtree rooted at a right child of a node of P 2 ) Arne Storjohann (CS, UW) CS240 - Module 7 Fall 2010 5 / 21

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

View Full Document
One-Dimensional Range Search P 1 : path traversed in BST-Search ( T , k 1 ) P 2 : path traversed in BST-Search ( T , k 2 ) k
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}