Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started