Hi,
Why we are not passing any arguments to the function buildTree() while printing the nodes?
thanks
Printing of binary tree
It is not necessary to pass it as a parameter. The root node must have been declared as global.
so how buildTree() will access subtree ?
please reply back to me
The root node was created locally inside the function and using recursion its left subtree and right subtree was built. So passing the root node as parameter is not required. Each recursive call returns the root node( you can notice that the return type of the function is node* ) created by it and eventually the final tree is formed.
Just try to trace the recursion. Draw the recursion stack and try to dry run the code one time yourself.