Relative Content

Tag Archive for binary-search-tree

What is wrong about my code which checks whether a binary tree is BST (binary search tree ) or not

In-order traversal of BST is in ascending order. I’m using this fact to check for valid BST. If minNum which is the previous node data is greater than the curr node it means it’s not the valid BST. I’m not sure what I’m doing wrong. I recursively go to left node , then check above said condition then go to right node and repeat this to traverse the whole tree.
Please tell me what I’m doing wrong and I don’t want any other method of solving this problem.
Thanks