Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following problem. You are given a set R of n rectangles, where each rectangle r e R has (0,0) as the lower-left corner.

image text in transcribed

Consider the following problem. You are given a set R of n rectangles, where each rectangle r e R has (0,0) as the lower-left corner. The upper-right corner has an integer x- and y-coordinate and each rectangle in R has a distinct upper-right corner. We say a point p = (x, y) stabs a rectangle if it lies inside the rectangle (including the borders). We develop a data structures where we can efficiently add and remove rectangles and for a given point can efficiently find a stabbed rectangle. We choose to store the rectangles in a red-black tree T by the x-coordinate of their right- upper corner. Moreover, we augment each node v in the red-black tree by the maximum y-coordinate of the upper-right corner of any rectangle in the subtree rooted at v. (a) [1 points] Prove that the augmentation can be maintained without affecting the asymp- totic runtimes when inserting or removing a rectangle from the tree. (b) [1 points) To understand how this augmentation may help us consider the following case. Assume that at the root r of T the rectangle with upper-right corner (6,11) is stored and that the query point p = (7,8) If p stabs a rectangle where in the RB-tree can this rectangle be stored? (c) [4 points) Describe an algorithm that given a query point q can find a stabbed rectangle in T in O(log n) time. You may assume such a rectangle exists. Also analyse the runtime of your algorithm and argue its correctness. Consider the following problem. You are given a set R of n rectangles, where each rectangle r e R has (0,0) as the lower-left corner. The upper-right corner has an integer x- and y-coordinate and each rectangle in R has a distinct upper-right corner. We say a point p = (x, y) stabs a rectangle if it lies inside the rectangle (including the borders). We develop a data structures where we can efficiently add and remove rectangles and for a given point can efficiently find a stabbed rectangle. We choose to store the rectangles in a red-black tree T by the x-coordinate of their right- upper corner. Moreover, we augment each node v in the red-black tree by the maximum y-coordinate of the upper-right corner of any rectangle in the subtree rooted at v. (a) [1 points] Prove that the augmentation can be maintained without affecting the asymp- totic runtimes when inserting or removing a rectangle from the tree. (b) [1 points) To understand how this augmentation may help us consider the following case. Assume that at the root r of T the rectangle with upper-right corner (6,11) is stored and that the query point p = (7,8) If p stabs a rectangle where in the RB-tree can this rectangle be stored? (c) [4 points) Describe an algorithm that given a query point q can find a stabbed rectangle in T in O(log n) time. You may assume such a rectangle exists. Also analyse the runtime of your algorithm and argue its correctness

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions

Question

How does that affect your approach to complaint handling?

Answered: 1 week ago

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago