Docsity

Spatial Data Structures - Sample Homework 4 | CMSC 420, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
CMSC$420$Homework$4:$Spatial$Data$Structures$
Handed&out&on&April&8,&2008,&and&due&on&Thursday,&April&17,&2008&at&the&beginning&of&class.&
Remember:&write&your&own&answers&and&use&English&or&pseudocode&when&algorithms&are&
requested.&Late&homeworks&will&not&be&accepted&(turn&in&whatever&you&have).&&
Problem$0.&Consider&the&following&sequence&of&points:&
(74,&42)&&(90,&84)&&(93,&78)&&(39,&17)&&(83,&47)&&(98,&13)&&(10,&3)&&(46,&64)&&(44,&2)&&(5,&94)&
Show&the&result&of&inserting&the&above&sequence&of&points&in&the&order&given&into&each&of&the&
following&kinds&of&trees:&
a) PR&quadtree&
b) MX&quadtree&(assume&smallest&square&is&1x1)&
c) Point&quadtree&
d) Kd‐tree&(assume&the&root&splits&on&the&x‐dimension)&
For&each&problem,&show&the&resulting&tree&as&well&as&the&space&decomposition&in&the&usual&
way.&Show&your&work&if&you&want&partial&credit.&
Problem$1.$Consider&the&kd‐tree&shown&at&right.&Assume&by&
convention&points&with&equal&coordinates&in&the&cutting&
dimension&are&put&into&right&subtrees.&&
a)&Show&the&result&of&deleting&(15,&70).&
b)&Starting&afresh&with&the&tree&at&right,&show&the&result&of&
deleting&(22,&75).&&
$
Problem$2.$Suppose&nodes&v1,…,vn&of&a&tree&T&contain&data&points.&Define&the&total%path%
length&to&be&TPL(T)&=&∑i&path(vi),&where&path(u)&is&the&length&of&the&path&from&the&root&to&u.&
In&other&words,&TPL(T)&is&the&sum&of&the&lengths&of&the&paths&to&each&of&the&nodes&
containing&data.&&Consider&the&sequence&of&points:&
(7,&63)&(1,&42)&(20,&57)&(67,&27)&(52,&96)&(49,&60)&(28,&61)&(71,&60)&&
Give&an&ordering&of&these&points&so&that&if&they&are&inserted&into&a&kd‐tree&in&that&order,&the&
TPL&of&the&resulting&tree&is&…&
a)&minimized&
b)&maximized&
Show&the&resulting&trees.&
Problem$3.$Give&(1)&a&PR&quadtree&instance&that&contains&at&least&5&points&and&(2)&a&
rectangular&range&query&on&that&tree&such&that&the&range&contains&no&points&but&the&entire&
quadtree&must&be&traversed&using&the&standard&range&search&algorithm&discussed&in&class,&
or&argue&why&that&can’t&happen.&
30,20
15,70 78,8
3,25 22,75
14,90
14,98
1,10 20,55

Partial preview of the text

Download Spatial Data Structures - Sample Homework 4 | CMSC 420 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

CMSC 420 Homework 4: Spatial Data Structures

Handed out on April 8, 2008, and due on Thursday, April 17, 2008 at the beginning of class. Remember: write your own answers and use English or pseudocode when algorithms are requested. Late homeworks will not be accepted (turn in whatever you have). Problem 0. Consider the following sequence of points: (74, 42) (90, 84) (93, 78) (39, 17) (83, 47) (98, 13) (10, 3) (46, 64) (44, 2) (5, 94) Show the result of inserting the above sequence of points in the order given into each of the following kinds of trees: a) PR quadtree b) MX quadtree (assume smallest square is 1x1) c) Point quadtree d) Kd‐tree (assume the root splits on the x‐dimension) For each problem, show the resulting tree as well as the space decomposition in the usual way. Show your work if you want partial credit. Problem 1. Consider the kd‐tree shown at right. Assume by convention points with equal coordinates in the cutting dimension are put into right subtrees. a) Show the result of deleting (15, 70). b) Starting afresh with the tree at right, show the result of deleting (22, 75). Problem 2. Suppose nodes v 1 ,…,vn of a tree T contain data points. Define the total path length to be TPL(T) = ∑i path(vi), where path(u) is the length of the path from the root to u. In other words, TPL(T) is the sum of the lengths of the paths to each of the nodes containing data. Consider the sequence of points: (7, 63) (1, 42) (20, 57) (67, 27) (52, 96) (49, 60) (28, 61) (71, 60) Give an ordering of these points so that if they are inserted into a kd‐tree in that order, the TPL of the resulting tree is … a) minimized b) maximized Show the resulting trees. Problem 3. Give (1) a PR quadtree instance that contains at least 5 points and (2) a rectangular range query on that tree such that the range contains no points but the entire quadtree must be traversed using the standard range search algorithm discussed in class, or argue why that can’t happen. 30, 15,70 78, 3,25 22, 14, 14, 1,10 20,