Question: Given the Binary Tree class here Implement all the class methods of BinaryTree and its iterator. You may add any private methods or members you

Given the Binary Tree class here

Implement all the class methods of BinaryTree and its iterator. You may add any private methods or members you wish.

>>>>>>>>>>>>>>>>>>>>>> BinaryTree.h <<<<<<<<<<<<<<<<<<<<<<

#ifndef TREE_BINARYTREE_H #define TREE_BINARYTREE_H

class BinaryTree;

class Node { public: void preorderDump(); private: int m_data; };

class BinaryTree { public: BinaryTree(int rootData); class Iterator { public: Iterator(Node * node); bool operator!=(Iterator rhs); Iterator left(); Iterator right(); void insertLeft(int data); void insertRight(int data); private: // whatever you want to add };

Iterator root(); // prints the tree as preorder traversal void preorderDump(); };

#endif //TREE_BINARYTREE_H

>>>>>>>>>>>>>>>> test.cpp <<<<<<<<<<<<<<<

#include #include "BinaryTree.h"

int main() { BinaryTree tree(4); auto itr = tree.root(); itr.insertLeft(4); itr = itr.left(); itr.insertRight(5); tree.preorderDump(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!