Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Tree Data Structures

Tree datastructures.

2
Contains Zero (or) more nodes

Root, left subtree, right subtree

Node

link, Info, rlink

Node= llink + info + rlink

3
Indegree, outdegree,
degree of a node: number of branches
root node, child, siblings, parent, leaf, internal nodes, external nodes,
level: distance of a node from the root
Height: maximum level of any leaf node

4
Zero or two sub trees

An empty tree

Not more than 2 subtree

No two nodes should have same value

N elements has N-1 edges.

Binary tree of height h has atleast l and atmost


2h-1 elements

5
6
Strictly binary tree: out degree 0 or 2
Complete binary tree: non leaf node exactly
Has exactly 2 children

Skewed tree

Binary search tree

7
Insertion, deletion

Traversal

Searching

Copying

8
Visiting each node in a tree in systamatic manner.

Three types of tree traversals

Preorder tree traversals

Inorder tree traversals

Postorder tree traversals

9
Preorder: A B D H E C F G I J
Inorder : D H B E A F C I G J
Postorder: H D E B F I J G C A
10
11
12
Preorder: AB DH EC F G I J

Inorder : D HB EAF C I G J

Postorder: HDEBF IJGCA

13
14
15
16
Preorder: AB DG C EH I F

Inorder : DGBAHEICF

Postorder: GDBHIEFCA

17
18
Preorder: AB C EI F J D G HK L
Inorder: E I C F J B G D K H LA
Postorder: IEJFCGKLHDBA
19
20
21
22
23
24
25
Symbol table construction

Manipulation of arithmatic expression

Hierarchical database management system

File index schemes

26
27

You might also like