|
-
June 18th, 2009, 01:40 PM
#1
BST - Binary search Tree
Hi,
Write C++ program to check if a given binary tree is a binary search tree or not?
suggestions:
-------------
If the given binary tree is a Binary search tree, then the inorder traversal should output the elements in increasing order. We make use of this property of inorder traversal to check whether the given binary tree is a BST or not.
The problem here , if I print or insert the nodes according to InOrder Traversal to a buffer , then I can check the values by comparisons, and this final step will increase the complixity of the solution.
How can I do that in lower complixity, I mean without allocating a new buffer and traverse it.??
Thank you
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|