BinaryTree
of the text is given below.
The new member
template <class T> class BinaryTreeNode { friend BinaryTree<T>; private: T data; BinaryTreeNode<T> *LeftChild, // left subtree *RightChild; // right subtree }; template<class T> class BinaryTree { public: BinaryTree() {root = 0;}; ~BinaryTree(){}; T DeepestElement(); private: BinaryTreeNode<T> *root; // pointer to root };
DeepestElement returns
any one of the elements at the maximum level of the binary tree.
DeepestElement
member function. You may define and implement new private
member functions as needed.
You may not create or delete any nodes or invoke any binary tree functions
not defined in this problem unless you provide code for these functions.
MinHeap
is given below.
template<class T> class MinHeap { public: MinHeap(int MinHeapSize = 10); ~MinHeap() {delete [] heap;} MinHeap<T>& Insert(const T& x); MinHeap<T>& DeleteMin(T& x); MinHeap<T>& ChangeMin(const T& x); private: T *heap; // 1D array int CurrentSize, // number currently in heap MaxSize; // capacity of heap[] }; template<class T> MinHeap<T>::MinHeap(int MinHeapSize) {// Min heap constructor. MaxSize = MinHeapSize; heap = new T[MaxSize+1]; CurrentSize = 0; }
ChangeMin
member function.
This function replaces the current min element with x
and restructures the min heap as necessary.
You may not invoke either Insert
or DeleteMin.
ABCDEFGHIJ, and when they are output in preorder,
the output is
ADBCJGFEHI.
Draw the binary tree showing the data in each node and the pointers between
nodes.
feedback form |
permissions |
international |
locate your campus rep |
request a review copy
Copyright ©2001 The McGraw-Hill Companies.
digital solutions |
publish with us |
customer service |
mhhe home
Any use is subject to the
Terms of Use and Privacy Policy.
McGraw-Hill Higher Education is one of the many fine businesses of the
The McGraw-Hill Companies.