IT245 - Module 6
IT245 - Module 6
26/12/2021
1
College of Computing and
Informatics
Data Structure
2
Data Structure
Module 6
Tree – Part 1
3
1. Fundamental / Structure of the Trees
2. Tree Traversals with an Application
3. Implementation Binary Trees
4. Binary Search Tree
5. Tree Traversal (Revisited, detailed example)
Contents
4
1. Understand Search Tree Abstract Data Type
5
Required Reading
1. Chapter 4 (Data structures and algorithm
analysis in Java by Mark Allen Weiss)
Recommended Reading
1. Chapter 12 (al, Cormen Thomas H et. Introduction to
Algorithms. Cambridge, MA: MIT Press, 2009)
2. Binary Tree, Introduction:
https://www.geeksforgeeks.org/binary-tree-set-1-introduction/
6
• Fundamental / Structure of the Trees
7
Fundamental / Structure of the Trees
8
Fundamental / Structure of the Trees
9
Fundamental / Structure of the Trees
10
Fundamental / Structure of the Trees
• Since the number of children per node can vary so greatly and is not
known in advance,
• it might be infeasible to make the children direct links in the data structure,
• because there would be too much wasted space.
• The solution is simple: Keep the children of each node in a linked list of tree
nodes.
11
• Tree Traversals with an Application
12
Tree Traversals with an Application
13
Tree Traversals with an Application
14
Tree Traversals with an Application
• Thus, the total amount of work is constant per node. If there are N file names
to be output, then the running time is O(N).
15
Tree Traversals with an Application
16
Tree Traversals with an Application
17
• Implementation Binary Trees
18
Implementation Binary Trees
19
Implementation Binary Trees
20
Implementation Binary Trees
(1)
(2) 21
Implementation Binary Trees
(3)
(4) 22
Implementation Binary Trees
(5)
(6) 23
Thank
You
24