
CMSC 420: Data Structures
Fall 2003
Homework 2
Due: Nov. 11, 2003.
QUESTION 1 (10 points). Suppose
๎
is a pointer to the root of a PR-quadtree. Assume that all
nodes have REG ,NW,S W,NE, SE fields respectively denoting the implicit region represented by
the node, and the four directional pointers. Given
๎
and a point
๎๎๎๎
๎๎๎๎๎
as input, you must write
an algorithm that prints out the
๎
points stored in the tree that are as far away from point
๎๎๎๎
๎๎๎๎๎
as possible. You may assume that the distance between two points
๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎
is given by
๎
๎๎๎๎๎๎๎๎๎๎๎๎๎
๎๎๎
๎๎๎๎๎๎๎๎๎๎๎๎๎
๎
. The order in which the answers are printed is significant - the most
distant point from
๎๎๎๎๎๎๎๎๎
is printed out first, the second most distant point from
๎๎๎๎๎๎๎๎๎
is printed out
next, and so on. If multiple values are at the same distance from
๎๎๎๎๎๎๎๎๎
those values can be printed
out in any relative order.
QUESTION 2(10 points). Suppose you are given a pointer
๎
to the root of an
๎
-tree. Suppose
each node in the
๎
-tree can contain at most
๎
rectangles in it. You are also given as input, a query
rectangle
. Write, in pseudo code, an algorithm that finds all rectangles in the
๎
-tree that do not
intersect
. You may assume the existence of some function
๎"!$#๎๎"๎&%('*)
that takes two rectangles as
input and returns true if they intersect and false otherwise.
1