The suggestion will work if the root is known to have entry equal to zero. (Even it is less than 0, there is a chance that a negative an reside in right sub-tree whose value is < 0 but greater than the negative value of the root). If the entry of the root is zero then we can do the inorder traversal. Also if the BST is rooted tree (say there is a special mark for identifying the root) then we can identify the root and use this to terminate the algorithm after printing the result.
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.