Question: 2. A research project needs a data structure D that supports the operations min, extract-min, max, extract-max, and insert(x). You know n, the estimated maximum

2. A research project needs a data structure D that supports the operations min, extract-min, max, extract-max, and insert(x). You know n, the estimated maximum number of el- ements in D, but you do not know anything about the values of the elements. The implementation can use only one array A of size n +1, plus a constant number of addi- tional variables. One array location should contain one data element. A student who has taken Algorithm course last year proposes the following heap-like structure D: (1) The root of the tree contains no element. (II) The left subtree is a heap with min value at the root (min-heap), and the right subtree is a heap with max value at the root (max-heap). (III) Each element of the min-heap is less than or equal to the element in the same position in the max-heap. (IV) If there are k, k
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
