GDC Class Notes

Class Notes of Graduate Diploma in Computing in Unitec

Binary Search Tree Structure and algorithm

Traversals

  • Preorder Traversal, Process(Root), GotoLeft, GotoRight
1
2
3
4
5
process(root);

preOrder(leftSubtree);

preOrder(rightSubtree);
  • InOrder, GotoLeft, Process, GotoRight

    1
    // This will get a ordered list
  • PosrOrder, Left, Right, Process

    1
    2
    3
    // If we put operators to root, and number to lefts,

    // then this order will match postFix (expression)

And these 3 different orders can match the prefix, infix, postfix expressions.