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

Assignment Help:

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

}


Related Discussions:- Test whether a binary tree is a binary search tree

Program of insertion of an element in list, Program will demonstrate the in...

Program will demonstrate the insertion of an element at desired position /* Inserting an element into contiguous list (Linear Array) at particular position */ /* contiguous_

State about the pseudocode, State the Introduction to pseudocode No spe...

State the Introduction to pseudocode No specific programming language is referred to; development of algorithms by using pseudocode uses generic descriptions of branching, loop

Draw trace table and determine output of number, Draw trace table and deter...

Draw trace table and determine output from the following flowchart using following data: Number = 45, -2, 20.5

Stack making use of the linked list, Q. Implement a stack making use of the...

Q. Implement a stack making use of the linked list. Show the PUSH and POP operations both. A n s . Stack implemantation using linked list # include # include

Data Warehousing, Assume you are in the insurance business. Find two exampl...

Assume you are in the insurance business. Find two examples of Type 2 slowly changing dimensions in that business. As an analyst on the project, write the specifications for applyi

Advanced data structures, In this unit, the following four advanced data st...

In this unit, the following four advanced data structures have been practically emphasized. These may be considered as alternative to a height balanced tree, i.e., AVL tree.

Define about the structure - container, Define about the Structure - Contai...

Define about the Structure - Container - Some containers hold elements in some sort of structure, and some don't. Containers with no structure include bags and sets. Containe

Acyclic graph, Tree is a widely used data structure employed for representi...

Tree is a widely used data structure employed for representing several problems. We studied tree like a special case of acyclic graph. Though, rooted trees are most prominent of al

Rooted tree, It does not have any cycles (circuits, or closed paths), which...

It does not have any cycles (circuits, or closed paths), which would imply the existence of more than one path among two nodes. It is the most general kind of tree, and might be co

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd