q. write down an algorithm to test whether a


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);

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: q. write down an algorithm to test whether a
Reference No:- TGS0156807

Expected delivery within 24 Hours