That would work. But a simpler approach is:
bool isBinTree(root *t)
{
return (!t) || ((!t->left || (t->value > t->left->value)) &&
(!t->right || (t->value < t->right->value)) &&
isBinTree(t->left) && isBinTree(t->right));
}
On Nov 5, 2:04 pm, shady <[email protected]> wrote:
> Hi,
> Can we check this by just doing an inorder traversal, and then checking if
> it is in increasing order or not ?
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.