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.

The next question uses the following class, which represents a binary tree:

Inorder traversal:

4 2 5 1 6 3 7

1 2 3 4 5 6 7

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!