Question
The next question uses the following class, which represents a binary tree: // C++ class Tree { private: struct TreeNode { int value; TreeNode *left;
The next question uses the following class, which represents a binary tree:
// C++
class Tree {
private:
struct TreeNode {
int value;
TreeNode *left;
TreeNode *right;
};
//points to the top node
TreeNode *root;
public:
Tree() {root=NULL;}
void inorder();
};
2- Define the public member function inorder() that displays the
elements of the tree by visiting the nodes following an in-order traversal. In
this traversal method, the left subtree is visited first, then the root and later the
right sub-tree (see the example below, and note that the tree is not required to be a binary search tree). You may add new private functions to the class as
needed.
Inorder traversal:
4 2 5 1 6 3 7
1 2 3 4 5 6 7Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started