Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions