Implement in-order traversal using C++ program
belongs to collection: Data Structure programs using C and C++ (Sorting Programs)
All Answers
total answers (1)
belongs to collection: Data Structure programs using C and C++ (Sorting Programs)
total answers (1)
Algorithm:
inorder(root) a. Traverse the left subtree (inorder(root->left)) b. visit the root c. Traverse the right subtree (inorder(root->right))2. by non recursive method
This method is implemented by the use of stack.
a. create an empty stack b. initialize current node as root node. c. push current into the stack while current->left != NULL update current as current=current->left d. repeat while current is NULL and stack is not empty 1. pop the element from the stack and update current equal to the popped element 2. print info of current 3.update current=current->rightC++ code to implement in-order traversal
Output