Tree-In Data Structure
TREE
BY:
Samrin Ahmed Riya
ID: 011142021
Sanzida Akter
ID: 011142032
leaves
branches
root
root
nodes
leaves
branches
 Connected graph.Connected graph.
 Acyclic graph.
 A finite non-empty set of elements.
 CConsisting of nodes with a parent-child
relation.
Introduction of a Tree
B C
FD E G
A
Family Structures of a Tree
 Root-node without parent (A)
 Siblings-nodes share the same parent.
Internal node-node with at least one child (A, B, C, E)
External node (leaf): node without children (D,F,G, H, I)
Ancestors of a node: parent, grandparent, grand-
grandparent, etc.
Descendant of a node: child, grandchild, grand-grandchild,
etc.
Depth of a node: number of ancestors
Height of a tree: maximum depth of any node (3)
Degree of a node: the number of its children
Degree of a tree: the maximum number of its node.
 Subtree: tree consisting of a node and its descendants
Tree-In Data Structure
Left Child Right Sibling
Representation
Data
Left Child Right
Sibling
A
B C D
IHGFE
J K L
 Preorder Sequence.
 Inorder Sequence.
 Postorder Sequence.
 Level order Sequence
Tree Traversal Technique
Tree Traversal Technique
Preorder Inorder Postorder Level order
Tree Traversal Technique
(CONT.)
Preorder Sequence:
 Visits the nodes of a tree in a systematic manner
 A node is visited before its descendants
 Application: print a structured document
Algorithm:
void preorder(node *root){
if(root!=NULL){
printf(“%c”,root->data);
if(root->left!=NULL)
preorder(root->left);
if(root->right!=NULL)
preorder(root->right);
}
}
Tree-In Data Structure
Inorder Sequence:
 A node is visited after its left subtree and before its right sub
tree
Algorithm :
void inorder(node *root){
if(root!=NULL){
if(root->left!=NULL)
inorder(root->left);
printf(“%c”,root->data);
if(root->right!=NULL)
inorder(root->right);
}
}
Tree-In Data Structure
Postorder Sequence:
 A node is visited after its descendants
 Application: compute space used by files in a
directory and its subdirectories
Algorithm :
void postorder(node *root){
if(root!=NULL){
if(root->left!=NULL)
postorder(root->left);
if(root->right!=NULL)
postorder(root->right);
printf(“%c”,root->data);
}
}
Tree-In Data Structure
Level order Sequence:
 A node is traversed in a level by level
order.
Algorithm :
Queue<-root
while Queue !=Empty
v<-Queue
visit v
Visited Sequence<-v
if left(v) !=NULL then
Queue<-left(v)
if right(v) !=NULL then
Queue<-right(v)
endwhile
return Visited Sequence
Tree-In Data Structure
 Each internal node has at most two children
(degree of two)
 The children of a node are an ordered pair
Alternative Recursive Defintion:
 A tree consisting of a single node, or
 A tree whose root has an ordered pair of children.
Applications:
 Arithmetic expressions.
 Decisions process searching.
 Searching.
A
B C
F GD E
H I
Strict Binary Tree:
 Each node exactly having two or zero child.
Full Binary Tree:
 Each node exactly having two node or zero
child and leaf node at the same level.
Complete Binary Tree:
 All leaf node is at the same height.
 No missing node in the sequence.
Strict Binary Tree
Full Binary Tree
A
B C
GE
I
D
H
F
Complete Binary Tree
A
B C
GF
Basic Operations:
 Inserting an element into tree.
 Deleting an element from tree.
 Searching for an element.
 Traversing the tree.
Auxiliary Operations:
 Finding size of tree.
 Calculating height of tree.
 Expressions trees are used in compiler.
 Huffman coding trees which are used in data
compression technique.
 Binary Search Tree (BST) supports insertion & deletion
of node with o(log n)
 Priority queue supports search and deletion of min or
max on a collection of items in a logarithmic times.
Method 1:
 height=max(level(i))
Method 2:
 height= log2(n)
Method 3:
 height(T)=max(height(Tl),height(Tr))+1
Algorithm :
int height(node *root){
if(root==NULL)
return -1;
else if(root->left==NULL && root->right==NULL)
return 0;
else
return max(height(root->left),height(root->right))+1;
}
Int max(int x,int y){
if(x>y)
return x;
else
return y;
}
https://en.wikipedia.org/wiki/Tree_%28data_stru cture%29
 http://www.slideshare.net/samsumitgupta/trees-data-structure
 http://www.i-programmer.info/babbages-bag/477-trees.html
 https://www.cse.iitb.ac.in/~cs101/pdfs/Trees.ppt
Tree-In Data Structure
Tree-In Data Structure

More Related Content

PPTX
Tree in data structure
PPTX
Trees (data structure)
PPSX
Data Structure (Tree)
PPTX
trees in data structure
PPTX
Types of Tree in Data Structure in C++
PPTX
Threaded Binary Tree
PPTX
Tree in data structure
PPTX
Tree Traversal
Tree in data structure
Trees (data structure)
Data Structure (Tree)
trees in data structure
Types of Tree in Data Structure in C++
Threaded Binary Tree
Tree in data structure
Tree Traversal

What's hot (20)

PPTX
PPTX
Threaded Binary Tree.pptx
PPTX
PPTX
Binary Tree in Data Structure
PDF
Lecture notes data structures tree
PPT
Binary Search Tree and AVL
PPT
Binary tree
PPTX
Binary Search Tree
PPT
1.1 binary tree
PPTX
Terminology of tree
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPTX
Binary Search Tree
PDF
Expression trees
PPTX
AVL Tree Data Structure
PPTX
single linked list
PPTX
Trees data structure
PPT
Binary search trees
PPTX
Binary tree
PPT
Binary tree
Threaded Binary Tree.pptx
Binary Tree in Data Structure
Lecture notes data structures tree
Binary Search Tree and AVL
Binary tree
Binary Search Tree
1.1 binary tree
Terminology of tree
Trees, Binary Search Tree, AVL Tree in Data Structures
Binary Search Tree
Expression trees
AVL Tree Data Structure
single linked list
Trees data structure
Binary search trees
Binary tree
Binary tree
Ad

Viewers also liked (20)

PPTX
Arduino Based Parking Lot System
PPTX
AUTOMATIC CAR PARKING SYSTEM
PPTX
smart parking system
PPTX
State fair project ( Remote Car Parking System)
PPTX
project
PDF
S4A A7: Servos de posición
PDF
S4A A3: Parking con pulsadores
PDF
S4A: Sensores de distancia
PDF
S4A: A1 Empezamos con S4a
PDF
S4A A2: Hacemos un semáforo
PDF
S4A A5: Control LED RGB
PDF
S4A A4: Objetos Inteligentes
PPTX
Reverse car-parking
PPT
Arduino aplicado a la maqueta digital
PPTX
INTELLIGENT PARKING LOT SYSTEM
PDF
Open hardware - Primeros pasos con Arduino
PDF
Introducción a Arduino - Parte I
PPTX
Projet Robotic parking system à Casablanca
Arduino Based Parking Lot System
AUTOMATIC CAR PARKING SYSTEM
smart parking system
State fair project ( Remote Car Parking System)
project
S4A A7: Servos de posición
S4A A3: Parking con pulsadores
S4A: Sensores de distancia
S4A: A1 Empezamos con S4a
S4A A2: Hacemos un semáforo
S4A A5: Control LED RGB
S4A A4: Objetos Inteligentes
Reverse car-parking
Arduino aplicado a la maqueta digital
INTELLIGENT PARKING LOT SYSTEM
Open hardware - Primeros pasos con Arduino
Introducción a Arduino - Parte I
Projet Robotic parking system à Casablanca
Ad

Similar to Tree-In Data Structure (20)

PPTX
Why Tree is considered a non-linear data structure?
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PPT
Lecture 5 tree.pptx
PPT
Data Structure And Algorithms for Computer Science
PPTX
Tree Data Structure & methods & operations
PPTX
tree Data Structures in python Traversals.pptx
PPTX
Unit-VStackStackStackStackStackStack.pptx
PPTX
Data structure using c module 2
PPTX
PPTX
Unit 6 tree
PPTX
PPT
Admissions in india 2015
PPTX
Unit – vi tree
PPTX
binary tree.pptx
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PPTX
Data Structure in Tree form. .pptx
PPTX
lecture 17,18. .pptx
PPTX
lecture 17,18. .pptx
PPT
ds 10-Binary Tree.ppt
Why Tree is considered a non-linear data structure?
UNIT III Non Linear Data Structures - Trees.pptx
Lecture 5 tree.pptx
Data Structure And Algorithms for Computer Science
Tree Data Structure & methods & operations
tree Data Structures in python Traversals.pptx
Unit-VStackStackStackStackStackStack.pptx
Data structure using c module 2
Unit 6 tree
Admissions in india 2015
Unit – vi tree
binary tree.pptx
UNIT III Non Linear Data Structures - Trees.pptx
Data Structure in Tree form. .pptx
lecture 17,18. .pptx
lecture 17,18. .pptx
ds 10-Binary Tree.ppt

More from United International University (13)

PPTX
Digital Banking - Revolution in Bangladesh
PPTX
Happiness advantage
DOCX
Project report on arduino based parking lot system
DOCX
Talk shows-Are they entertaining ?
PPTX
PPTX
Systematic Project Implementation
PPTX
Project Management Tools
PPTX
Peephole Optimization
PPTX
Balanced Tree (AVL Tree & Red-Black Tree)
PPTX
Academic Pressure Too Much To Handle
PPT
Cinema & Its Impact On Society
PPT
Cyber Crime-The New War of the 21st Century
Digital Banking - Revolution in Bangladesh
Happiness advantage
Project report on arduino based parking lot system
Talk shows-Are they entertaining ?
Systematic Project Implementation
Project Management Tools
Peephole Optimization
Balanced Tree (AVL Tree & Red-Black Tree)
Academic Pressure Too Much To Handle
Cinema & Its Impact On Society
Cyber Crime-The New War of the 21st Century

Recently uploaded (20)

PDF
Delhi c@ll girl# cute girls in delhi with travel girls in delhi call now
PPTX
Evaluasi program Bhs Inggris th 2023-2024 dan prog th 2024-2025-1.pptx
PPTX
Dkdkskakkakakakskskdjddidiiffiiddakaka.pptx
PPT
Handout for Lean and Six Sigma application
PPTX
Bussiness Plan S Group of college 2020-23 Final
PPTX
cyber row.pptx for cyber proffesionals and hackers
PDF
American Journal of Multidisciplinary Research and Review
PDF
Mcdonald's : a half century growth . pdf
PPTX
Fkrjrkrkekekekeekkekswkjdjdjddwkejje.pptx
PDF
toaz.info-grade-11-2nd-quarter-earth-and-life-science-pr_5360bfd5a497b75f7ae4...
PPTX
Sistem Informasi Manejemn-Sistem Manajemen Database
PPTX
Sheep Seg. Marketing Plan_C2 2025 (1).pptx
PDF
Lesson 1 - intro Cybersecurity and Cybercrime.pptx.pdf
PPTX
The future of AIThe future of AIThe future of AI
PPTX
ISO 9001-2015 quality management system presentation
PPTX
Transport System for Biology students in the 11th grade
PDF
PPT IEPT 2025_Ms. Nurul Presentation 10.pdf
PPT
DWDM unit 1 for btech 3rd year students.ppt
PPTX
UNIT-1 NOTES Data warehousing and data mining.pptx
PPTX
Stats annual compiled ipd opd ot br 2024
Delhi c@ll girl# cute girls in delhi with travel girls in delhi call now
Evaluasi program Bhs Inggris th 2023-2024 dan prog th 2024-2025-1.pptx
Dkdkskakkakakakskskdjddidiiffiiddakaka.pptx
Handout for Lean and Six Sigma application
Bussiness Plan S Group of college 2020-23 Final
cyber row.pptx for cyber proffesionals and hackers
American Journal of Multidisciplinary Research and Review
Mcdonald's : a half century growth . pdf
Fkrjrkrkekekekeekkekswkjdjdjddwkejje.pptx
toaz.info-grade-11-2nd-quarter-earth-and-life-science-pr_5360bfd5a497b75f7ae4...
Sistem Informasi Manejemn-Sistem Manajemen Database
Sheep Seg. Marketing Plan_C2 2025 (1).pptx
Lesson 1 - intro Cybersecurity and Cybercrime.pptx.pdf
The future of AIThe future of AIThe future of AI
ISO 9001-2015 quality management system presentation
Transport System for Biology students in the 11th grade
PPT IEPT 2025_Ms. Nurul Presentation 10.pdf
DWDM unit 1 for btech 3rd year students.ppt
UNIT-1 NOTES Data warehousing and data mining.pptx
Stats annual compiled ipd opd ot br 2024

Tree-In Data Structure

  • 2. TREE BY: Samrin Ahmed Riya ID: 011142021 Sanzida Akter ID: 011142032
  • 5.  Connected graph.Connected graph.  Acyclic graph.  A finite non-empty set of elements.  CConsisting of nodes with a parent-child relation. Introduction of a Tree B C FD E G A
  • 6. Family Structures of a Tree  Root-node without parent (A)  Siblings-nodes share the same parent. Internal node-node with at least one child (A, B, C, E) External node (leaf): node without children (D,F,G, H, I) Ancestors of a node: parent, grandparent, grand- grandparent, etc. Descendant of a node: child, grandchild, grand-grandchild, etc. Depth of a node: number of ancestors Height of a tree: maximum depth of any node (3) Degree of a node: the number of its children Degree of a tree: the maximum number of its node.  Subtree: tree consisting of a node and its descendants
  • 8. Left Child Right Sibling Representation Data Left Child Right Sibling A B C D IHGFE J K L
  • 9.  Preorder Sequence.  Inorder Sequence.  Postorder Sequence.  Level order Sequence Tree Traversal Technique Tree Traversal Technique Preorder Inorder Postorder Level order
  • 10. Tree Traversal Technique (CONT.) Preorder Sequence:  Visits the nodes of a tree in a systematic manner  A node is visited before its descendants  Application: print a structured document Algorithm: void preorder(node *root){ if(root!=NULL){ printf(“%c”,root->data); if(root->left!=NULL) preorder(root->left); if(root->right!=NULL) preorder(root->right); } }
  • 12. Inorder Sequence:  A node is visited after its left subtree and before its right sub tree Algorithm : void inorder(node *root){ if(root!=NULL){ if(root->left!=NULL) inorder(root->left); printf(“%c”,root->data); if(root->right!=NULL) inorder(root->right); } }
  • 14. Postorder Sequence:  A node is visited after its descendants  Application: compute space used by files in a directory and its subdirectories Algorithm : void postorder(node *root){ if(root!=NULL){ if(root->left!=NULL) postorder(root->left); if(root->right!=NULL) postorder(root->right); printf(“%c”,root->data); } }
  • 16. Level order Sequence:  A node is traversed in a level by level order. Algorithm : Queue<-root while Queue !=Empty v<-Queue visit v Visited Sequence<-v if left(v) !=NULL then Queue<-left(v) if right(v) !=NULL then Queue<-right(v) endwhile return Visited Sequence
  • 18.  Each internal node has at most two children (degree of two)  The children of a node are an ordered pair Alternative Recursive Defintion:  A tree consisting of a single node, or  A tree whose root has an ordered pair of children. Applications:  Arithmetic expressions.  Decisions process searching.  Searching. A B C F GD E H I
  • 19. Strict Binary Tree:  Each node exactly having two or zero child. Full Binary Tree:  Each node exactly having two node or zero child and leaf node at the same level. Complete Binary Tree:  All leaf node is at the same height.  No missing node in the sequence.
  • 20. Strict Binary Tree Full Binary Tree A B C GE I D H F Complete Binary Tree A B C GF
  • 21. Basic Operations:  Inserting an element into tree.  Deleting an element from tree.  Searching for an element.  Traversing the tree. Auxiliary Operations:  Finding size of tree.  Calculating height of tree.
  • 22.  Expressions trees are used in compiler.  Huffman coding trees which are used in data compression technique.  Binary Search Tree (BST) supports insertion & deletion of node with o(log n)  Priority queue supports search and deletion of min or max on a collection of items in a logarithmic times.
  • 23. Method 1:  height=max(level(i)) Method 2:  height= log2(n) Method 3:  height(T)=max(height(Tl),height(Tr))+1
  • 24. Algorithm : int height(node *root){ if(root==NULL) return -1; else if(root->left==NULL && root->right==NULL) return 0; else return max(height(root->left),height(root->right))+1; } Int max(int x,int y){ if(x>y) return x; else return y; }
  • 25. https://en.wikipedia.org/wiki/Tree_%28data_stru cture%29  http://www.slideshare.net/samsumitgupta/trees-data-structure  http://www.i-programmer.info/babbages-bag/477-trees.html  https://www.cse.iitb.ac.in/~cs101/pdfs/Trees.ppt