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
1. In computer science, a classic problem is how to dynamically store information so as to let for quick look up. This searching problem arises frequently in dictionaries, symbol t


A representation of an array structure is a mapping of the (abstract) array with elements of type T onto the store which is an array with elements of type BYTE. The array could be

Q. Write down any four applications or implementation of the stack.                                     Ans. (i)       The Conversion of infix to postfix form (ii)

important points on asymptotic notation to remember

Multilist Representation of graph

what are registers? why we need register? Definition? Types? What registers can do for us?

1. Give both a high-level algorithm and an implementation (\bubble diagram") of a Turing machine for the language in Exercise 3.8 (b) on page 160. Use the ' notation to show the co

How to create multiple queue on single array?

how to write a pseudo code using Kramer''s rule