wrote recursive printing for preorder and postorder