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 1. Explain the different types of traversal on binary tree 2. Explain the Prim's minimum spanning tree algorithm 3. Differentiate fixed and variable storage allo

1) preorder, postorder and inorder 2) The main feature of a Binary Search Tree is that all of the elements whose values is less than the root reside into the nodes of left subtr

Full Binary Trees: A binary tree of height h that had 2h -1 elements is called a Full Binary Tree. Complete Binary Trees: A binary tree whereby if the height is d, and all of

Overlapping or Intersecting A polygon overlaps or intersects the current background if any of its sides cuts the edges of the viewport as depicted at the top right corner of th

HOW LINKED LIST HEADER WORKS? HOW TO INSERT AND DELETE ELEMENTS IN LINKED LIST?


Easy algorithm for beginner for quicksort with explanation

What is a height balanced tree? Height Balanced Tree (AVL Tree) An AVL tree is a binary search tree in which the height of the left and right subtree of the root vary by at most

Sorting Algorithm A sorting algorithm is an algorithm which puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Eff

Describe different methods of developing algorithms with examples.