Docsity

Solved Questions on Data Structures - Homework 2 | CMSC 420, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
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

Partial preview of the text

Download Solved Questions on Data Structures - Homework 2 | CMSC 420 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

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,SW,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.