Preorder tree traversal recursion?
I know the recursive implementation for a preorder tree traversal, but I’m not sure how it works. Like when it goes through the very first branch until it gets to the last left leaf, I understand how it works up to that. But I don’t understand how it goes back up to a node that has a right subtree. Say the root has 2 children and those children each have 2 children. The base case would be when the node passed in is null , beginning with the root. It would first print the root, then call the function on the root’s left node, print that node, and then print the left node of that node. Then, The leftmost node will check its left and right which are both null. But how does the function go back up the subtree to process the right node of the first left child?