SlideShare a Scribd company logo
TREE DATA STRUCTURE EXAMPLE:COMPUTERFILE
SYSTEM
A HYPOTHETICAL FAMILY TREE
A tree consists of a finite set of
elements, called nodes, and a
finite set of directed lines, called
branches, that connect the nodes.
TREE ADT
⦿Tree is a non-linear data structure which organizes data in recursive
hierarchical structure.
⦿In tree data structure, every individual element is called as Node.
⦿Node in a tree data structure stores the actual data of that particular
element and link to next element in hierarchical structure.
STRUCTURE OF A TREE
⦿There is one and only one path between every pair of nodes in a tree.
TREE TERMINOLOGY
ROOT NODE
⦿In a tree data structure, the first
node is called as Root Node.
⦿Every tree must have a root
node.
⦿In any tree, there must be only
one root node.
EDGE
⦿The connecting link between any two nodes is called as EDGE.
⦿In a tree with 'N' number of nodes there will be a maximum of 'N-1'
number of edges.
PARENT NODES
CHILD NODES
ANCESTOR AND DESCENDANT
⦿Ancestors: Any node in the path from the current node to the root node.
⦿Descendant: Any node in the path from the current node to the leaf
nodes..
⦿Ancestor(J)=E,B,A
⦿ Descendant(C)=G,K,H
SIBLINGS
LEAF NODES
⦿The leaf nodes are also called as External Nodes or Terminal Nodes
INTERNAL NODES
DEGREE
⦿The Degree of a node is total number of children it has.
⦿The highest degree of a node among all the nodes in a tree is called
as 'Degree of Tree'
LEVEL
⦿ In a tree each step from top to bottom is called as a Level and the Level
count starts with '0' and incremented by one at each step.
⦿Level- distance from the root node.
HEIGHT
⦿Height of all leaf nodes is 0.
DEPTH
⦿Depth of the root node is '0'
PATH
• Length of a Path is total number of edges in that path.
SUBTREE
⦿Each child node with a parent node forms a subtree recursively.
⦿Any connected structure below root is a subtree.
⦿Collection of subtrees makes a tree.
FOREST
⦿A forest is a set of disjoint trees.
COMPARISON
ReoI
Leeł Noda
&aval0
Levei 1
APPLICATION OF TREE
CLASSIFY THE TWO TRAVERSALS PERFORMED IN TREE ADT.
⦿ A traversal of a tree requires that each node of the tree be visited
once
⦿ A typical reason to traverse a tree is to display the data stored at each
node of the tree
⦿Traversal Types
⦿ preorder
■ Inorder
■ Postorder
■ level-order
LEVEL ORDER TRAVERSAL
Traversal
⦿Starts at the root node and explores as deep as possible along each
branch and backtrack to sibling branch until all nodes are visited.
⦿It is a recursive approach for all subtrees.
PREORDER TRAVERSAL
⦿Processing order: Root → Left → Right
Algorithm
1. Visit the root
2. Traverse the left sub tree i.e. call Preorder (left sub tree)
3. Traverse the right sub tree i.e. call Preorder (right sub tree)
EXAMPLE
Traverse the entire tree starting iron the root rode keeping yourself to theleft.
Preorder Traversal : A , B, D, E, C, F, G
INORDER TRAVERSAL
⦿Processing order: Left → Root → Right
Algorithm
1. Traverse the left sub tree i.e. call Inorder (left sub tree)
2. Visit the root
3. Traverse the right sub tree i.e. call Inorder (right sub tree)
EXAMPLE
tree Data Structures in python Traversals.pptx
POSTORDER TRAVERSAL
⦿Processing order: Left → Right → Root
Algorithm
1. Traverse the left sub tree i.e. call Postorder (left sub tree)
2. Traverse the right sub tree i.e. call Postorder (right sub tree)
3. Visit the root
EXAMPLE
Postorder Traversal Shortcut
EXERCISE
Q1
1. Visit the following tree in a breadth first
manner and print all the nodes.
ANSWER
Binary Tree
Expression Tree
Binary Search Tree
Trees
AVL Tree
B Tree
Heap Tree
TYPES OF TREES
BINARY TREE AND ITS RELATED OPERATIONS
⦿ A tree whose elements have at most 2 children is called a binary tree.
Since each element in a binary tree can have only 2 children, we
typically name them the left and right child.
⦿ A Binary Tree node contains following parts.
■ Data
■ Pointer to left child
■ Pointer to right child
BINARY TREE
⦿A node can have 0,1, and 2 children in a binary tree
CONT..
⦿In a tree each node contains information and may or may not contain
links.
PROPERTIES OF BINARY TREE
⦿At any level ‘i’, maximum number of nodes possible is 2^i
⦿ Maximum number of nodes of height h=
CONT..
⦿ Minimum number of nodes of height h=h+1
CONT..
CONT..
⦿Maximum height of the tree if minimum number of nodes is given is
(n-1)
CONT..
⦿ Minimum height of the tree if maximum number of possible nodes is
given by
TYPES OF BINARY TREE
⦿ Full/Strict/ Proper Binary Tree
⦿Complete Binary Tree
⦿Perfect Binary Tree
⦿Degenerate Binary Tree
⦿ Balanced Binary Tree
⦿ Unbalanced Binary Tree
FULL BINARY TREE
⦿It is a binary tree where each node will contains exactly two children
except leaf node
Full Binary Tree
COMPLETE BINARY TREE
⦿It is a binary tree where all levels are completely filled (except possibly
the last level) and the last level has nodes as left as possible
Complete binary tree
PERFECT BINARY TREE
⦿It is a binary tree where all internal nodes have 2 children and all
leaves are at same level
⦿A perfect binary tree is a complete binary tree or full binary tree but
vice versa is not true
DEGENERATE BINARY TREE
⦿It is a binary tree where all internal nodes are having only one child
BALANCED BINARY TREE
⦿Find Balance Factor, B=HL-HR
⦿HL- height of left subtree; HR-height of right subtree
⦿The height of the left and right subtrees differs by no more than one i.e.,
its balance factor of every node should be –1, 0, or +1
UNBALANCED BINARY TREE

More Related Content

PPT
SQL subquery
PDF
[APJ] Common Table Expressions (CTEs) in SQL
 
PPTX
Quick_sort1.pptx
PDF
Binary tree
PDF
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
PPTX
Binary tree
PPTX
Stack project
PPTX
Sql(structured query language)
SQL subquery
[APJ] Common Table Expressions (CTEs) in SQL
 
Quick_sort1.pptx
Binary tree
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Binary tree
Stack project
Sql(structured query language)

What's hot (20)

PPTX
Sparse matrix and its representation data structure
PPTX
PPTX
MySql Triggers Tutorial - The Webs Academy
PPT
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
PPTX
Creating a Binary tree from a General Tree.pptx
PPT
Binary tree
PPTX
Skip lists (Advance Data structure)
PPTX
Avl trees
PPT
address-translation-mechanism-of-80386 (1).ppt
PPTX
Application of Stack - Yadraj Meena
PPTX
Joins And Its Types
PPTX
Arboles Binarios y Arboles Binarios de Busqueda
PDF
Data manipulation language
PPT
Red black tree
PPTX
trees in data structure
PDF
Tree and binary tree
PPTX
Data structures - unit 1
PDF
UNIT I LINEAR DATA STRUCTURES – LIST
PDF
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
PPTX
set operators.pptx
Sparse matrix and its representation data structure
MySql Triggers Tutorial - The Webs Academy
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
Creating a Binary tree from a General Tree.pptx
Binary tree
Skip lists (Advance Data structure)
Avl trees
address-translation-mechanism-of-80386 (1).ppt
Application of Stack - Yadraj Meena
Joins And Its Types
Arboles Binarios y Arboles Binarios de Busqueda
Data manipulation language
Red black tree
trees in data structure
Tree and binary tree
Data structures - unit 1
UNIT I LINEAR DATA STRUCTURES – LIST
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
set operators.pptx
Ad

Similar to tree Data Structures in python Traversals.pptx (20)

PPTX
Tree all information about tree concept are available .
PPTX
Data Structure of computer science and technology
PPT
Lecture 5 tree.pptx
PPT
Final tree.ppt tells about tree presentation
DOCX
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
PPT
9. TREE Data Structure Non Linear Data Structure
DOCX
Trees and Graphs in data structures and Algorithms
PPT
Binary search Tree and avl tree , treee.ppt
PPTX
Tree.pptx
PPT
UNIT-4 TREES.ppt
PPTX
Data Structures -Non Linear DS-Basics ofTrees
PPT
358 33 powerpoint-slides_10-trees_chapter-10
PPT
Tree and Binary Search tree
PPTX
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
PPTX
PPTX
Basic Tree Data Structure BST Traversals .pptx
PPTX
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PDF
unit-2-dsa-tree-2024-1 (1) (1).pdf data structure
PDF
Dsc++ unit 3 notes
Tree all information about tree concept are available .
Data Structure of computer science and technology
Lecture 5 tree.pptx
Final tree.ppt tells about tree presentation
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
9. TREE Data Structure Non Linear Data Structure
Trees and Graphs in data structures and Algorithms
Binary search Tree and avl tree , treee.ppt
Tree.pptx
UNIT-4 TREES.ppt
Data Structures -Non Linear DS-Basics ofTrees
358 33 powerpoint-slides_10-trees_chapter-10
Tree and Binary Search tree
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
Basic Tree Data Structure BST Traversals .pptx
UNIT III Non Linear Data Structures - Trees.pptx
unit-2-dsa-tree-2024-1 (1) (1).pdf data structure
Dsc++ unit 3 notes
Ad

More from RupaRaj6 (20)

PPTX
object oriented programming-classes and objects.pptx
PPTX
C++Object oriented Programming with C++.pptx
PPTX
Exception Handling in C++-Brief notes.pptx
PPTX
chapter 5 Templates-Introduction in C++.pptx
PPTX
Data Structures using Queue,linear,circular-2 Q.pptx
PDF
Lecture13.pdf UNIT 4 In digital logic Circuits
PPTX
AIPPTMaker_OLAP vs OLTP_ A Comprehensive Comparison (1).pptx
PPT
03 Data Mining Concepts and TechniquesPreprocessing.ppt
PPT
counters Digital Logic Circuits Counters module 4-.ppt
PPT
Preprocessing steps in Data mining steps
PPTX
Association Rule Mining, Correlation,Clustering
PPTX
DATA MODELLING-Knowledge engineering.pptx
PDF
actor_critic_pdf in Reinforcement learning.pdf
PPTX
TRPO PPO in reinforcement learning.pptx
PDF
MIT Normalization and its types with examples.pdf
PPT
Chapter_1_Digital_Systems_and_Binary_Numbers.ppt
PDF
Encoder and Decoder establishmen t
PPTX
Web crawler and web App Pgm Interface.pptx
PPTX
UNIT-2.pptx Data Collection and data management
PPTX
UNIT 1.pptx
object oriented programming-classes and objects.pptx
C++Object oriented Programming with C++.pptx
Exception Handling in C++-Brief notes.pptx
chapter 5 Templates-Introduction in C++.pptx
Data Structures using Queue,linear,circular-2 Q.pptx
Lecture13.pdf UNIT 4 In digital logic Circuits
AIPPTMaker_OLAP vs OLTP_ A Comprehensive Comparison (1).pptx
03 Data Mining Concepts and TechniquesPreprocessing.ppt
counters Digital Logic Circuits Counters module 4-.ppt
Preprocessing steps in Data mining steps
Association Rule Mining, Correlation,Clustering
DATA MODELLING-Knowledge engineering.pptx
actor_critic_pdf in Reinforcement learning.pdf
TRPO PPO in reinforcement learning.pptx
MIT Normalization and its types with examples.pdf
Chapter_1_Digital_Systems_and_Binary_Numbers.ppt
Encoder and Decoder establishmen t
Web crawler and web App Pgm Interface.pptx
UNIT-2.pptx Data Collection and data management
UNIT 1.pptx

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPT
Project quality management in manufacturing
PDF
Digital Logic Computer Design lecture notes
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Well-logging-methods_new................
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Sustainable Sites - Green Building Construction
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Project quality management in manufacturing
Digital Logic Computer Design lecture notes
additive manufacturing of ss316l using mig welding
Foundation to blockchain - A guide to Blockchain Tech
UNIT 4 Total Quality Management .pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Internet of Things (IOT) - A guide to understanding
Well-logging-methods_new................
Model Code of Practice - Construction Work - 21102022 .pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Sustainable Sites - Green Building Construction
CH1 Production IntroductoryConcepts.pptx
bas. eng. economics group 4 presentation 1.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf

tree Data Structures in python Traversals.pptx