Binary Trees Exercises

  < Previous  Next >
  1. Modify traverse() by adding the call "visit( currNode);"
    to make it {pre,in,post}orderTraverse().
    void traverse( TreeNode* currNode){
        if( currNode != nullptr ){
            traverse( currNode->getLeftTree());
            traverse( currNode->getRightTree());
        }
    }
    

    preorderTraverse():




    inorderTraverse():




    postorderTraverse():




  2. Given the following tree, write the values of the nodes
    in the order that they are traversed.

    Preorder Traversal:




    Inorder Traversal:




    Postorder Traversal:




Last Modified: