Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design an efficient algorithm (pseudo code) that add an interval with integer end points to a set of disjoint intervals to form a new set

Design an efficient algorithm (pseudo code) that add an interval with integer end points to a set of disjoint intervals to form a new set of disjoint intervals such that the overlapping intervals are merged into a new interval. For example, given a set of disjoint intervals [-5, 0], [2, 4], [5, 8], [10, 15], [17, 20], [25, 30]; adding a new interval [3, 12] results in the new set of disjoint intervals [-5, 0], [2, 15], [17, 20], and [25, 30]. The initial set of disjoint intervals can be in random order. Analyze the time complexity of your algorithm in terms of the size n of the set of disjoint intervals. image text in transcribed

Note: - You first need to briefly explain your ideas to solve the problem, e.g. what data structures are used, how the intermediate results are saved, which sorting strategy is used, and why the final results are correct; - Your pseudo code needs to follow the format given in the textbook (e.g. Partition procedure ): PARTITION (A,p,r) You can also use any procedures/functions defined in the textbook in your pseudo code. Concrete code from a specific programming language such as Python or Java copied from elsewhere is NOT acceptable. - You always need to provide a complexity analysis for your algorithmic design or description

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions