Answered step by step
Verified Expert Solution
Link Copied!

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 Node(N) where N is the numeric value for the Root.
Change Left Index Calculation: 2*index +1 to a << Leftptr of the Node
Change Right Index Calculcation: 2*index+2 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 *pleft,*pright;
public:
node(T t){ tdata = t; pleft = NULL; pright = NULL; }
T data(){ return tdata; }
node* left(){ return pleft; }
void setleft(node* pn){ pleft = pn; }
node* right(){ return pright; }
void setright(node* pn){ pright = pn; }};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

2. How are individual tastes encoded?

Answered: 1 week ago

Question

5. Explain how ERISA protects employees pension rights.

Answered: 1 week ago