Test whether a binary tree is a binary search tree, Data Structure & Algorithms

Q. Write down an algorithm to test whether a Binary Tree is a Binary Search Tree.             

Ans.

The algorithm to check whether a Binary tree is as Binary Search tree is as

follows:

bstree(*tree)

{

while((tree->left !=null)&& (tree->right !=null))

{

if(tree->left < tree->root)

bstree(tree->left);

else return(1);

if(tree->right > tree->root)

bstree(tree->right);

else return(1);

}

return(0);

}

Posted Date: 7/13/2012 3:11:54 AM | Location : United States







Related Discussions:- Test whether a binary tree is a binary search tree, Assignment Help, Ask Question on Test whether a binary tree is a binary search tree, Get Answer, Expert's Help, Test whether a binary tree is a binary search tree Discussions

Write discussion on Test whether a binary tree is a binary search tree
Your posts are moderated
Related Questions
Q. Write down the algorithm for binary search. Which are the conditions under which sequential search of a list is preferred over the binary search?

What data structure would you mostly likely see in a nonrecursive execution of a recursive algorithm? Stack

1)    The set of the algorithms whose order is O (1) would run in the identical time.  True/False 2)    Determine the complexity of the following program into big O notation:

Deletion in a RBT uses two main processes, namely, Procedure 1: This is utilized to delete an element in a given Red-Black Tree. It involves the method of deletion utilized in


I need a person who has a good background in using R. Studio? In adition, a person who is good in using algorithms.


What do you understand by term structured programming? Explain the structured programming as well.                                 Ans. S tructured Programming is expla

Importance of Object-Oriented over java Java is basically based on OOP notions of classes and objects. Java uses a formal OOP type system that should be obeyed at compile-t

Arrays are simple, however reliable to employ in more condition than you can count. Arrays are utilized in those problems while the number of items to be solved out is fixed. They