Binary Search Tree is a binary tree where left child of a node is less than the key of the Parent node and the key in the right child is greater than the parent node.We can design many kind of BST(Binary Search Tree) for some nodes or values.And there average searching time may be different.In Binary Search tree searching is easy. Time complexity of searching in case BST is nlogn.
Binary Tree |
1) Inorder Traversal.(Left,Root,Right)
2) Preorder Traversal.(Root,Left,Right)
3) Postorder Traversal.(Left,Right,Root)
For the above tree: Inorder Traversal is 5 , 10 , 12 , 20 , 30.
Preorder Traversal is 20 , 10 , 5 , 12 , 30.
Postorder Traversal is 5 , 12 , 10 , 30 , 20.
No comments:
Post a Comment