I have a question on how this binary tree traversal code works.
void BinaryTree_Functions::preorder(Binary_TreeNode* bt)
{
if (bt == NULL) { return; }
cout << bt->data <<endl;
preorder(bt->Left);
preorder(bt->Right);
}
preorder traversal
void BinaryTree_Functions::inorder(Binary_TreeNode* bt)
{
if (bt == NULL) { return; }
inorder(bt->Left);
cout << bt->data << endl;
inorder(bt->Right);
}
inorder traversal
void BinaryTree_Functions::postorder(Binary_TreeNode* bt)
{
if (bt == NULL) { return; }
postorder(bt->Left);
postorder(bt->Right);
cout << bt->data << endl;
}
postorder traversal
I know how these traversals work but I did not understand the code.