Binary Search Tree

advertisement
Types of Binary Trees
Introduction
Types of Binary Trees


1.
2.
3.
4.
There are several types of binary trees possible each
with its own properties.
Few important and frequently used trees are listed as
below:
Binary search tree
Expression tree
Heap tree
Threaded Binary tree
Types of Binary Trees
5.
6.
7.
8.
9.
10.
Height balanced tree(AVL tree)
2-3 Trees
Weight Balanced tree
m-ary Trees tree
Trie Structures tree
B/B+ tree
Binary Search Tree

A binary search tree T is termed as binary Search tree
(or binary sorted tree) if each node N of T satisfies the
following property:
 The value of the node in the left childe or Left sub
tree is less than the value of the root.
 The value of the node in the right child or right sub
tree is more than or equal to the value of the root.
 All the sub trees of the left & right children observe
above two rules.
Binary Search Tree

Exampel-1
Binary Search Tree

Example-2
Basic Operation on Binary Search Tree




Inserting any data into it
Deletion any data from it
Searching for a data
Traversing the data
What is different between Tree, Binary tree
& Binary Search tree?




A tree is a data structure that only allows one parent
but multiple children.
A Binary Search tree is a specific case of a tree.
First, it is a binary tree, meaning that a node can at
most have two children. Here, sorting not imported.
And it is a binary search tree meaning that the left
child of a value is less than the parent value while
the right child value is greater than the parent value.
Traversal of a Binary Search Tree

There are:



Preorder traversal (PLR)
Inorder traversal(LPR)
Postorder traversal(LRP)
Traversal of a Binary Search Tree
Traversal of a Binary Search Tree

Sequence of the previous example:



Preorder traversal (PLR)
16,10,5,14,25,18,90
Inorder traversal(LPR)
5,10,14,16,18,25,90
Postorder traversal(LRP)
5,14,10,18,90,25,16
Traversal of a Binary Search Tree
Traversal of a Binary Search Tree

Sequence of the previous example:



Preorder traversal (PLR)
P,H,A,D,K,M,S,R,T,W
Inorder traversal(LPR)
A,D,H,K,M,P,R,T,S,W
Postorder traversal(LRP)
D,A,M,K,H,T,R,W,S,P
Download