Bst created in pre- order, inorder and post order, Data Structure & Algorithms

Q. Make a BST for the given sequence of numbers.

45,32,90,34,68,72,15,24,30,66,11,50,10 Traverse the BST formed in  Pre- order, Inorder and Postorder.                                                                                                             

Ans:

The property which makes a binary tree into a binary search tree is that for each and every node, X, in the tree, values of all the keys in the left subtree are smaller than the key value in X, and values of all the keys in the right subtree are greater than the key value in X.

The Binary Search Tree for given data 45, 32, 90, 34, 68, 72, 15, 24, 30, 66, 11,

50, 10 is as follows:

 

1714_BST.png

The traversals for the tree shown above is as follows: - Pre-order traversal is- 45 , 32, 15, 11, 10, 24, 30, 34, 90, 68, 66, 50, 72

Inorder traversal given as follows:-

10, 11, 15, 24, 30, 32, 34, 45, 50, 66, 68, 72, 90

Postorder traversal is given as follows:-

10, 11, 30, 24, 15, 34, 32, 50, 66, 72, 68, 90, 45

Posted Date: 7/10/2012 7:20:53 AM | Location : United States







Related Discussions:- Bst created in pre- order, inorder and post order, Assignment Help, Ask Question on Bst created in pre- order, inorder and post order, Get Answer, Expert's Help, Bst created in pre- order, inorder and post order Discussions

Write discussion on Bst created in pre- order, inorder and post order
Your posts are moderated
Related Questions
(a) Describe the steps involved in the process of decision making under uncertainty. (b) Explain the following principles of decision making: (i) Laplace, (ii) Hurwicz. (c

In the previous unit, we have discussed arrays. Arrays are data structures of fixed size. Insertion and deletion involves reshuffling of array elements. Thus, array manipulation

There are ten stations on a railway line: Train travels in both directions (i.e. from 1 to 10 and then from 10 to 1).  Fare between each station is $2. A passenger input

What is an unreachable code assertion An unreachable code assertion can be placed at the default case; if it's every executed, then program is in an erroneous state. A loop in

memory address of any element of lower left triangular sparse matrix

an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

Graph terminologies : Adjacent vertices: Two vertices a & b are said to be adjacent if there is an edge connecting a & b. For instance, in given Figure, vertices 5 & 4 are adj

How sparse matrix stored in the memory of a computer?

In the book the following methods are presented: static void selectionSort(Comparable[] list) static void insertionSort(Comparable[] list) static boolean linearSearch(Comparable

The pre-order and post order traversal of a Binary Tree generates the same output. The tree can have maximum One node