Question: c + + please In the Heap Exercise an array was used to construct a minheap and maxheap. Convert your Heap to a Treap. A
c please In the Heap Exercise an array was used to construct a minheap and maxheap. Convert your Heap to a Treap. A Treap is a node pointer version of the heaps internal array. Replace the vector in the Heap with: Node Root new NodeN where N is the numeric value for the Root.
Change Left Index Calculation: index to a Leftptr of the Node
Change Right Index Calculcation: index to a RightPtr of the Node
A Treap Tree Heap is a form of binary search tree data structure that maintains the heap properties and allows binary searches among the keys.
Node Definition:
template
class node
T tdata;
node pleftpright;
public:
nodeT t tdata t; pleft NULL; pright NULL;
T data return tdata;
node left return pleft;
void setleftnode pn pleft pn;
node right return pright;
void setrightnode pn pright pn; ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
