binary search tree in order

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mishink7
    New Member
    • Apr 2007
    • 9

    binary search tree in order

    im having trouble with an inorder traversal algorithim to find the next node in the tree when given a certain node.

    would it be easier to do this recursively?

    any help on how to go about this or to start this is much appreciated..th anks
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    From what I've seen, the traversal algorithms for BSTs are recursive (though they can be implemented with iteration). You have to think about how each node is defined:

    Anything less than the current node is to the node's left, and
    Anything greater than the current node is to the node's right.

    An inorder traversal says you perform some operation to the smallest value first, then the next largest, then the next largest...and finally the largest node. This indicates that, for any node, the operation must be done to the left node before it can be done to the current node, and after this, the operation can be passed to the right node.

    Comment

    Working...