Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem is about using randomness to maintain balance in a binary search tree, thus yielding a dictionary data structure with expected cost O(log n)

This problem is about using randomness to maintain balance in a binary search tree, thus yielding a dictionary data structure with expected cost O(log n) for search, insert and delete. As usual, each element in the dictionary has a key attached to it. In addition, we will associate a priority with each element. The priority of an element will be chosen at random when the element is first inserted into the dictionary. Assume that the priorities are independent random variables. Assume for ease of analysis that keys are distinct and priorities are distinct. The search tree will be in binary search order with respect to the keys and simultaneously in heap order with respect to the priorities (minimum priority at the root).

(a) [5 marks] Prove that given the keys and priorities there is a unique tree with these ordering requirements.

(b) [5 marks] Prove that such a tree has expected height O(log n).

(c) [5 marks] Describe how to insert in time O(h) where h is the height of the tree. You may assume that rotation routines are given, i.e. you do not need to give details about implementing rotations. (Delete can also be done in O(h) time, but you do not need to prove that for this assignment.)

image text in transcribed

2 [15 marks] This problem is about using randomness to maintain balance in a binary search tree, thus yielding a dictionary data structure with expected cost O(log n) for search, insert and delete. As usual, each element in the dictionary has a key attached to it. In addition, we will associate a priority with each element. The priority of an element will be chosen at random when the element is first inserted into the dictionary. Assume that the priorities are independent random variables. Assume for ease of analysis that keys are distinct and priorities are distinct. The search tree will be in binary search order with respect to the keys and simultaneously in heap order with respect to the priorities (minimum priority at the root (a) [5 marks] Prove that given the keys and priorities there is a unique tree with these ordering requirements. (b) [5 marks] Prove that such a tree has expected height O(log n) (c) [5 marks] Describe how to insert in time O(h) where h is the height of the tree. You may assume that rotation routines are given, i.e. you do not need to give details about implementing rotations. (Delete can also be done in O(h) time, but you do not need to prove that for this assignment.)

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

Step: 3

blur-text-image

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Question What happens to my plan if I die?

Answered: 1 week ago