Unit-3 Non-Linear Data Structure Part-2 (Tree - II)
Unit-3 Non-Linear Data Structure Part-2 (Tree - II)
GTU # 3130702
Unit-3
Non-Linear Data Structure
Tree Part-2
1. Preorder Traversal
2. Inorder Traversal B D
3. Postorder Traversal
C E G
C ✓ E ✓ G ✓
F ✓
C ✓ E ✓ G ✓
F ✓
2 3 25 3 1
75
6 22
4 22 40 60 80
5 45
5
15 30 90
23 65
34 78
A
B D
B D
C E G
C E G
F
F
Postorder : G D B H I E F C
AA
A A
Inorder : D G BAA H E I C F
B C B C
A
D, E
D,G, H,E,I,C, H,E,I F D F
G
B F
G H I
G G G
QBKCF
PED HR B P B P
A
D Q A D
Q A
G
KC C E R
B E HR
P F
KCF ED H K F H
Q
A R
A
B D
B D
C E G
C E G
F
F
Because the left or right link of a node can denote either structural link or a thread, we
must somehow be able to distinguish them
B D A
C E G
B D
C E G
Inorder Traversal
C B A E F D G
F
B E
A
C D F H
B E
G
Inorder Traversal
C D F H
CBDAFGEH
G
#3130702 (DS) Unit 3 – Non-Linear Data Structure (Tree
Dr. Pradyumansinh U. Jadeja 19
Advantages of Threaded Binary Tree
Inorder traversal is faster than unthreaded version as stack is not required.
Effectively determines the predecessor and successor for inorder traversal, for unthreaded
tree this task is more difficult.
A stack is required to provide upward pointing information in binary tree which threading
provides without stack.
It is possible to generate successor or predecessor of any node without having over head of
stack with the help of threading.
50
25 75
22 40 60 80
15 30 90
Delete node a
a Delete node a b
Delete node a
a C
b C
Thank
You