Hi guys, how can I write a simple program which returns true if the given binary tree is binary search tree and false otherwise...
Hi guys, how can I write a simple program which returns true if the given binary tree is binary search tree and false otherwise...
Recursion! Look at the current node. If there are no children, return true. If there are child nodes, then depending on if it is a left or right child, the value contained in that child should either be less-than or greater-than the current node's value. If not what you expected, then return false otherwise you then need to recurse through those children.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Thanks for your reply...