Implement deleteTree function which deletes all the nodes of thetree
//tree.cpp
#include <iostream>
#include “tree.hpp”
using namespace std;
#define COUNT 10
/*
Constructor for a Tree object
*/
Tree::Tree()
{
this->root = NULL;
}
/*
Prints a binary tree in a 2D fashion.
Note: The image of the tree is left rotated by 90 degrees.
*/
void Tree::print2DUtil(Node *root, int space)
{
// Base case
if (root == NULL)
return;
// Increase distance between levels
space += COUNT;
// Process right child first
print2DUtil(root->right, space);
// Print current node after space
// count
printf(“n”);
for (int i = COUNT; i < space; i++)
printf(” “);
printf(“%dn”, root->data);
// Process left child
print2DUtil(root->left, space);
}
void Tree::preOrderTraverse(Node *node)
{
if (node == NULL)
return;
/* first print data of node */
cout << node->data << ” “;
/* then recur on left
PayPal Gateway not configured
PayPal Gateway not configured