Edit: Solved, see comments
I don't understand how the inorder traversal traverses through the whole tree. According to wikipedia, the pseudo code for the inorder traversal is:
sub P(TreeNode) If LeftPointer(TreeNode) != NULL Then P(TreeNode.LeftNode) Output(TreeNode.value) If RightPointer(TreeNode) != NULL Then P(TreeNode.RightNode) end sub
If I've understood correctly, then the algorithm above, for the BST below, would first traverse to the node with element 5 and then output it. After that, it checks whether the right child of that node is NULL, which it is. Doesn't the algorithm stop there?
Or is the pseudo code above incomplete? I have looked at quite a few sites and they all give the same short code. If it is incomplete, what would I have to add to the pseudocode so that it walks through the whole tree?