Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose we want to maintain a dynamic set S of n distinct numbers so as to support the following two operations: ( 1 ) Insert

Suppose we want to maintain a dynamic set S of n distinct numbers so as to support the following two operations: (1) Insert a number x into S, and (2) Report the minimum difference between two numbers in S. For example, if S={1,5,7,8,12}, then if we perform the report operation, the answer would be 1(where the minimum difference is from 7 and 8).
a. Describe a data structure that supports each insert in O(logn) time, so that each report can be performed in O(1) time. Also, briefly explain why the claimed time complexities are correct.
b.(Challenging) Suppose we now need an extra operation, which deletes a number x from S. For example, we may delete 7 from the previous S so that S becomes {1,5,8,12}. At this point, if we perform the report operation, we should answer 3. Describe a data structure that supports each insert or delete in Ologn time, while each report can still be performed in O(1) time. Also, briefly explain why the claimed time complexities are correct.
image text in transcribed

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

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions

Question

assess the infl uence of national culture on the workplace

Answered: 1 week ago