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
Explain Dijkstra's algorithm Dijkstra's algorithm: This problem is concerned with finding the least cost path from an originating node in a weighted graph to a destination node

Dequeue (a double ended queue) is an abstract data type alike to queue, where insertion and deletion of elements are allowed at both of the ends. Like a linear queue & a circular q

write a pseudocode to input the top speed (in km''s/hours) of 5000 cars output the fastest speed and the slowest speed output the average (mean) speed of all the 5000 cars answers

This is the most extensively used internal sorting algorithm. In its fundamental form, it was invented by C.A.R. Hoare in the year of 1960. Its popularity lies in the easiness of i

Materials consumed are priced in a systematic and realistic manner. It is argued that current acquisition costs are incurred for the purpose of meeting current production and sales

1. Use the Weierstrass condition, find the (Strongly) minimizing curve and the value of J min for the cases where x(1) = 0, x(2) = 3. 2. The system = x 1 + 2u; where

State the complex reallocation procedure Some languages provide arrays whose sizes are established at run-time and can change during execution. These dynamic arrays have an in

Write an algorithm to test whether a Binary Tree is a Binary Search Tree. The algorithm to test whether a Binary tree is as Binary Search tree is as follows: bstree(*tree) {

In this unit, we will describe a data structure called Graph. Actually, graph is a general tree along no parent-child relationship. In computer science, Graphs have several applica

circular queue using c