Question: NEEDS TO BE 2-3 TREE CANNOT USE B-TREES OR ANY OTHER TREE. 5. List maintenance (1). Consider the problem of maintaining a collection of lists
NEEDS TO BE 2-3 TREE CANNOT USE B-TREES OR ANY OTHER TREE.

5. List maintenance (1). Consider the problem of maintaining a collection of lists of items on which the following operations can be performed: (i) Create a new list with one item. (ii) Given two lists L1 and L2, form their concatenation L, i.e., the list consisting of all items in Li followed by all items in L2 (destroying Li and L2 in the process). (iii) Given a list L and a positive integer k, split L into two lists L1 and L2, where L consists of the first k items of L, and L2 the rest (L is destroyed in the process). (iv) Given a list L and a positive integer k, report the kth item in L. Describe data structures and algorithms supporting these operations so that operation (i) takes constant time, and operations (ii)(iv) can be performed in time O(log n) (where n is the length of L). Hint: Use a variation on 2-3 trees. Be sure to specify what information is stored at each node. Just sketch the algorithms, emphasizing the similarity and differences with algorithms for ordinary 2-3 trees. 5. List maintenance (1). Consider the problem of maintaining a collection of lists of items on which the following operations can be performed: (i) Create a new list with one item. (ii) Given two lists L1 and L2, form their concatenation L, i.e., the list consisting of all items in Li followed by all items in L2 (destroying Li and L2 in the process). (iii) Given a list L and a positive integer k, split L into two lists L1 and L2, where L consists of the first k items of L, and L2 the rest (L is destroyed in the process). (iv) Given a list L and a positive integer k, report the kth item in L. Describe data structures and algorithms supporting these operations so that operation (i) takes constant time, and operations (ii)(iv) can be performed in time O(log n) (where n is the length of L). Hint: Use a variation on 2-3 trees. Be sure to specify what information is stored at each node. Just sketch the algorithms, emphasizing the similarity and differences with algorithms for ordinary 2-3 trees
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
