The following function explains the inorder traversal of a Binary Tree , i.e. leftchild--node--right child :being its basic form.
| 19 | //The following function explains the inorder traversal of a Binary Tree , i.e. |
| 20 | // leftchild--node--right child :being its basic form. |
| 21 | void solve(TreeNode* A,vector<int> & result) |
| 22 | { if(A==NULL) return ;//BASE CASE IS IMP. ;in return nothing as void in func header |
| 23 | solve(A->left,result); |
| 24 | result.push_back(A->val); |
| 25 | solve(A->right,result); |
| 26 | } |
| 27 | |
| 28 | //The following function shows how we can call the inorder traversal function. |
| 29 |