Question: 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. Design an efficient algorithm (pseudo code) that add an interval with integer

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!