Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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 {

#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

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

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

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

43 Executive compensation methods. SPHR ONLY

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago