Question: 1. (10 marks) Consider an abstract data type that consists of a set S of positive integers upon which the following two operations can be

1. (10 marks) Consider an abstract data type that consists of a set S of positive integers upon which the following two operations can be performed DELETE(S, i): Delete integer i from the set S. If i S, there is no effect. SUCCESSOR(S' i): Return the successor of integer i in S, ie. minU s i j > i). If i has no successor in S. i.e. if i 2 max S, then return 0. Note that it is not necessary for i to be in S. Initially, S is a set of consecutive integers from a to b. For example, if a = 5,b = 10 then ini- tially S-(5, 6, 7, 8, 9, 10). After some DELETE() operations, suppose that S = {6, 8, 10) then SUCCESSOR(S, 14) 0, SUCCESSOR(S, 3) 6 and SUCCESSOR(S, 6) SUCCESSOR(S,7)- 8. In this question you will describe a data structure with O(a(n)) amortized cost per operation by answering the following questions. (c) Provide an algorithm for DELETE that takes (a(n amortized time. 1. (10 marks) Consider an abstract data type that consists of a set S of positive integers upon which the following two operations can be performed DELETE(S, i): Delete integer i from the set S. If i S, there is no effect. SUCCESSOR(S' i): Return the successor of integer i in S, ie. minU s i j > i). If i has no successor in S. i.e. if i 2 max S, then return 0. Note that it is not necessary for i to be in S. Initially, S is a set of consecutive integers from a to b. For example, if a = 5,b = 10 then ini- tially S-(5, 6, 7, 8, 9, 10). After some DELETE() operations, suppose that S = {6, 8, 10) then SUCCESSOR(S, 14) 0, SUCCESSOR(S, 3) 6 and SUCCESSOR(S, 6) SUCCESSOR(S,7)- 8. In this question you will describe a data structure with O(a(n)) amortized cost per operation by answering the following questions. (c) Provide an algorithm for DELETE that takes (a(n amortized time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
