C++ please... Build a templated max heap using a linked implementation. Insert 1
ID: 3845109 • Letter: C
Question
C++ please... Build a templated max heap using a linked implementation. Insert 100 unique random int’s into the heap. Display the heap. Then, delete the first 50 int’s that were inserted. Display the heap. Keep track of those first 50 int’s using an array or a vector. Display the heap in such a manner that the viewer is convinced that it is a heap. Now, repeat these actions but using an array implementation. Comparing the two implementations, which did you find easier to build and debug? C++ please... Build a templated max heap using a linked implementation. Insert 100 unique random int’s into the heap. Display the heap. Then, delete the first 50 int’s that were inserted. Display the heap. Keep track of those first 50 int’s using an array or a vector. Display the heap in such a manner that the viewer is convinced that it is a heap. Now, repeat these actions but using an array implementation. Comparing the two implementations, which did you find easier to build and debug?Explanation / Answer
template <class T>
class MinHeap {
private:
std::vector<T> _heap;
int _maxSize;
int _size;
public:
MinHeap(int maxSize);
~MinHeap();
void Insert(T elem);
T RemoveMin();
private:
int LeftChild(int pos);
int RightChild(int pos);
int Parent(int pos);
boolean IsLeaf(int pos);
void Swap(int pos1, int pos2);
void PushDown(int position);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.