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
#question.show that the following inequality is correct or incorrect. n!=O(n^n)

Optimal solution to the problem given below. Obtain the initial solution by VAM Ware houses Stores Availibility I II III IV A 5 1 3 3 34 B 3 3 5 4 15 C 6 4 4 3 12 D 4 –1 4 2 19 Re

Q. Convert the given infix expression into the postfix expression (also Show the steps) A ∗ (B + D)/ E - F(G + H / k ) Ans. Steps showing Infix to Post fix

Determine the class invariants- Ruby Ruby has many predefined exceptions classes (like ArgumentError) and new ones can be created easily by sub-classing StandardError, so it's

This algorithm inputs 3 numbers, every number goes through successive division by 10 until its value is less than 1. An output is produced which comprise the number input and a val

#question bubble sort..

Determine in brief about the Boolean Carrier set of the Boolean ADT is the set {true, false}. Operations on these values are negation, conjunction, disjunction, conditional,

Data records are stored in some particular sequence e.g., order of arrival value of key field etc. Records of sequential file cannot be randomly accessed i.e., to access the n th

#include #include int sumFact(int numb); int calculateFactorial(int digit); main() { int numb, sumfact; do{ printf ("Enter a number 1 to 9999\n"); scanf("%

Ask question #Minimum 10000 words accepted#