In this recipe, we will ask the user to enter a few numbers and build a binary tree from those numbers. Once the binary tree has been created, its inorder traversal is performed. These steps will be divided into two parts: creating the binary tree and traversing the binary tree in inorder.
Creating a binary search tree and performing an inorder traversal on it recursively
How to do it... – binary tree
Follow these steps to create the binary tree:
- Create a node with the following structure: data for storing tree elements, a right pointer to point at the right child of the tree, and a left pointer to point at the left child of the tree.
- Create the root node of the tree. To do this, allocate memory space for a new node...