types of binary trees introduction. types of binary trees there are several types of binary trees...

13
Types of Binary Trees Introduction

Upload: stewart-hall

Post on 11-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Types of Binary TreesIntroduction

Page 2: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Types of Binary Trees There are several types of binary trees possible each

with its own properties. Few important and frequently used trees are listed as

below:

1. Binary search tree

2. Expression tree

3. Heap tree

4. Threaded Binary tree

Page 3: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Types of Binary Trees5. Height balanced tree(AVL tree)

6. 2-3 Trees

7. Weight Balanced tree

8. m-ary Trees tree

9. Trie Structures tree

10. B/B+ tree

Page 4: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

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.

Page 5: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Binary Search Tree Exampel-1

Page 6: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Binary Search Tree Example-2

Page 7: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Basic Operation on Binary Search Tree

Inserting any data into it Deletion any data from it Searching for a data Traversing the data

Page 8: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

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.

Page 9: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Traversal of a Binary Search Tree There are:

Preorder traversal (PLR) Inorder traversal(LPR) Postorder traversal(LRP)

Page 10: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Traversal of a Binary Search Tree

Page 11: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

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

Page 12: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

Traversal of a Binary Search Tree

Page 13: Types of Binary Trees Introduction. Types of Binary Trees There are several types of binary trees possible each with its own properties. Few important

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