SlideShare a Scribd company logo
Tree
A tree is a (possibly non-linear) data structure made
up of nodes or vertices and edges without having
any cycle. The tree with no nodes is called
the null or empty tree. A tree that is not empty
consists of a root node and potentially many levels
of additional nodes that form a hierarchy.
 Root – The top node in a tree.
 Parent – The converse notion of child.
 Siblings – Nodes with the same parent.
 Leaf – a node with no children.
 Degree – number of sub trees of a node.
 Edge – connection between one node to another.
 Height of tree –The height of a tree is the number of
edges on the longest downward path between the root
and a leaf.
 Height of node –The height of a node is the number of
edges on the longest downward path between that node
and a leaf.
 Depth –The depth of a node is the number of edges
from the node to the tree's root node.
The simplest form of tree is a binary tree. A binary
tree consists of a node called the root node and
left and right sub-trees.
Both the sub-trees are themselves binary trees
.A binary tree is a tree data structure in which
each node has at most two children, which are
referred to as the left child and the right child
Tree
•Root Node:-Node at the "top" of a tree - the
one from which all operations on the tree
commence. The root node may not exist or
have 0, 1 or 2 children in a binary tree.
•Leaf Node:-Node at the "bottom" of a tree -
farthest from the root. Leaf nodes have no
children.
•Complete Tree:-Tree in which each leaf is
at the same distance from the root.
•Height:-Number of nodes which must be
traversed from the root to reach a leaf of a
tree.
Binary search trees (BST) are also known as
sorted binary trees, on which we can implement
“deletion, searching and inserting operation.
They store data items, known as nodes, and
allow fast insertion and deletion of such nodes,
as well as checking whether a node is present in
a tree. A binary search tree is a node-
based binary tree data structure where root
node has a comparable node and if node is
larger than the root node then it goes to right
sub-tree and smaller than the root node then the
node's goes to left sub-tree
•Check whether root node is present or not(tree
available or not).  If root is NULL, create root node.
•If the element to be inserted is less than the
element present in the root node , traverse the left
sub-tree recursively.
•If the element to be inserted is greater than the
element present in root node , traverse the right
sub-tree recursively.
 If(tree=NULL),then allocate space for node
 NEW[data]=NEW
 NEW[left]=NEW[right]=NULL
 Else IF(data<tree[data]),insert
element(tree(left),data)
 Else insert element(tree (right),data)
[End of if statement]
[End of if statement]
 Exit
 Check whether node to be searched is greater
then or smaller then then the root node and the
perform following steps.
 If the element to be searched is less than the
element present in the root node , traverse the left
sub-tree recursively.
 If the element to be searched is greater than the
element present in root node , traverse the right
sub-tree recursively.
•Searchelement(tree,val)
•If(tree=NULL),then
•Write:Tree is empty
•If(tree[data]=val),then
•Write:search is successful
•Else
•If(val<tree[data]),then
•Searchelement(tree[left],val)
•Else( (searchelement (tree[right],val).
•[End of if statement]
•[End of if statement]
•Exit

More Related Content

PPT
Tree data structure
Lovely Professional University
 
PPTX
Trees
Orphan Raj
 
PPTX
Unit 3 trees
LavanyaJ28
 
PPTX
Trees
Burhan Ahmed
 
PPTX
Trees data structure
Mahmoud Alfarra
 
PPTX
Tree data structure
Dana dia
 
PDF
Unit iv data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
PDF
Trees
Sadaf Ismail
 
Tree data structure
Lovely Professional University
 
Trees
Orphan Raj
 
Unit 3 trees
LavanyaJ28
 
Trees data structure
Mahmoud Alfarra
 
Tree data structure
Dana dia
 
Unit iv data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 

What's hot (20)

PPT
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
PPTX
Data structure tree - intermediate
MD. MARUFUZZAMAN .
 
PDF
Lecture notes data structures tree
maamir farooq
 
PPTX
Mca iii dfs u-4 tree and graph
Rai University
 
PPTX
trees in data structure
shameen khan
 
PPTX
Data structure tree - beginner
MD. MARUFUZZAMAN .
 
PPTX
Terminology of tree
RacksaviR
 
PPTX
Data structure tree- advance
MD. MARUFUZZAMAN .
 
PPT
ISDD Database Structure N5
Forrester High School
 
PPTX
Tree - Data Structure
Ashim Lamichhane
 
PPTX
Trees
surya pandian
 
PPT
Binary trees
Rajendran
 
PPTX
Lecture 9: Binary tree basics
Vivek Bhargav
 
PPT
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
PDF
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
PPTX
Treesandgraphs
Spencer Moran
 
PPT
tree in Data Structures
Shankar Bishnoi
 
PPTX
Tree(Data Structure)
FariaFerdowsy
 
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Data structure tree - intermediate
MD. MARUFUZZAMAN .
 
Lecture notes data structures tree
maamir farooq
 
Mca iii dfs u-4 tree and graph
Rai University
 
trees in data structure
shameen khan
 
Data structure tree - beginner
MD. MARUFUZZAMAN .
 
Terminology of tree
RacksaviR
 
Data structure tree- advance
MD. MARUFUZZAMAN .
 
ISDD Database Structure N5
Forrester High School
 
Tree - Data Structure
Ashim Lamichhane
 
Binary trees
Rajendran
 
Lecture 9: Binary tree basics
Vivek Bhargav
 
DATA STRUCTURES AND ALGORITHMS UNIT-3 TREES PREPARED BY M V BRAHMANANDA REDDY
Malikireddy Bramhananda Reddy
 
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Treesandgraphs
Spencer Moran
 
tree in Data Structures
Shankar Bishnoi
 
Tree(Data Structure)
FariaFerdowsy
 
Ad

Similar to Tree (20)

PPTX
Binary Search Tree.pptx
RaaviKapoor
 
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
PPTX
NON-LINEAR DATA STRUCTURE-TREES.pptx
Rajitha Reddy Alugati
 
PPTX
Trees.pptx
REMEGIUSPRAVEENSAHAY
 
PDF
Tree
maamir farooq
 
DOCX
Trees in data structrures
Gaurav Sharma
 
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
PDF
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
timoemin50
 
PPT
Trees
Shankar Bishnoi
 
PPTX
Data structures 3
Parthipan Parthi
 
DOCX
Biary search Tree.docx
sowmya koneru
 
PPTX
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
PPTX
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
tpvvsreenivasarao
 
PPTX
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
PPTX
Tree.pptx
worldchannel
 
PPT
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
PPTX
Why Tree is considered a non-linear data structure?
mominkainat05
 
PPT
UNIT-4 TREES.ppt
SIVAKUMARM603675
 
PPTX
Tree Data Structure & methods & operations
mmuhammadumar869
 
PDF
Chapter 7 - Binary Search Tree in the context of DSA.pdf
Dibyesh1
 
Binary Search Tree.pptx
RaaviKapoor
 
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
Rajitha Reddy Alugati
 
Trees in data structrures
Gaurav Sharma
 
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
timoemin50
 
Data structures 3
Parthipan Parthi
 
Biary search Tree.docx
sowmya koneru
 
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
tpvvsreenivasarao
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
Tree.pptx
worldchannel
 
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Why Tree is considered a non-linear data structure?
mominkainat05
 
UNIT-4 TREES.ppt
SIVAKUMARM603675
 
Tree Data Structure & methods & operations
mmuhammadumar869
 
Chapter 7 - Binary Search Tree in the context of DSA.pdf
Dibyesh1
 
Ad

More from Lovely Professional University (20)

PPTX
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Lovely Professional University
 
PPTX
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Lovely Professional University
 
PPTX
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Lovely Professional University
 
PPTX
Programme Management & Project Evaluation
Lovely Professional University
 
PPTX
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Lovely Professional University
 
PPTX
Introduction to Software Project Management:
Lovely Professional University
 
PDF
The HyperText Markup Language or HTML is the standard markup language
Lovely Professional University
 
PPTX
Working with JSON
Lovely Professional University
 
PPTX
NODEMON Module
Lovely Professional University
 
PPTX
Getting Input from User
Lovely Professional University
 
PPTX
fs Module.pptx
Lovely Professional University
 
PPTX
Transaction Processing in DBMS.pptx
Lovely Professional University
 
PPT
web_server_browser.ppt
Lovely Professional University
 
PPTX
Web Server.pptx
Lovely Professional University
 
PPTX
Number System.pptx
Lovely Professional University
 
PPT
Programming Language.ppt
Lovely Professional University
 
PPTX
Information System.pptx
Lovely Professional University
 
PPTX
Applications of Computer Science in Pharmacy-1.pptx
Lovely Professional University
 
PPTX
Application of Computers in Pharmacy.pptx
Lovely Professional University
 
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Lovely Professional University
 
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Lovely Professional University
 
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Lovely Professional University
 
Programme Management & Project Evaluation
Lovely Professional University
 
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Lovely Professional University
 
Introduction to Software Project Management:
Lovely Professional University
 
The HyperText Markup Language or HTML is the standard markup language
Lovely Professional University
 
Getting Input from User
Lovely Professional University
 
Transaction Processing in DBMS.pptx
Lovely Professional University
 
web_server_browser.ppt
Lovely Professional University
 
Number System.pptx
Lovely Professional University
 
Programming Language.ppt
Lovely Professional University
 
Information System.pptx
Lovely Professional University
 
Applications of Computer Science in Pharmacy-1.pptx
Lovely Professional University
 
Application of Computers in Pharmacy.pptx
Lovely Professional University
 

Recently uploaded (20)

PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
JUAL EFIX C5 IMU GNSS GEODETIC PERFECT BASE OR ROVER
Budi Minds
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
JUAL EFIX C5 IMU GNSS GEODETIC PERFECT BASE OR ROVER
Budi Minds
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
Software Testing Tools - names and explanation
shruti533256
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 

Tree

  • 2. A tree is a (possibly non-linear) data structure made up of nodes or vertices and edges without having any cycle. The tree with no nodes is called the null or empty tree. A tree that is not empty consists of a root node and potentially many levels of additional nodes that form a hierarchy.
  • 3.  Root – The top node in a tree.  Parent – The converse notion of child.  Siblings – Nodes with the same parent.  Leaf – a node with no children.  Degree – number of sub trees of a node.  Edge – connection between one node to another.  Height of tree –The height of a tree is the number of edges on the longest downward path between the root and a leaf.  Height of node –The height of a node is the number of edges on the longest downward path between that node and a leaf.  Depth –The depth of a node is the number of edges from the node to the tree's root node.
  • 4. The simplest form of tree is a binary tree. A binary tree consists of a node called the root node and left and right sub-trees. Both the sub-trees are themselves binary trees .A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child
  • 6. •Root Node:-Node at the "top" of a tree - the one from which all operations on the tree commence. The root node may not exist or have 0, 1 or 2 children in a binary tree. •Leaf Node:-Node at the "bottom" of a tree - farthest from the root. Leaf nodes have no children. •Complete Tree:-Tree in which each leaf is at the same distance from the root. •Height:-Number of nodes which must be traversed from the root to reach a leaf of a tree.
  • 7. Binary search trees (BST) are also known as sorted binary trees, on which we can implement “deletion, searching and inserting operation. They store data items, known as nodes, and allow fast insertion and deletion of such nodes, as well as checking whether a node is present in a tree. A binary search tree is a node- based binary tree data structure where root node has a comparable node and if node is larger than the root node then it goes to right sub-tree and smaller than the root node then the node's goes to left sub-tree
  • 8. •Check whether root node is present or not(tree available or not).  If root is NULL, create root node. •If the element to be inserted is less than the element present in the root node , traverse the left sub-tree recursively. •If the element to be inserted is greater than the element present in root node , traverse the right sub-tree recursively.
  • 9.  If(tree=NULL),then allocate space for node  NEW[data]=NEW  NEW[left]=NEW[right]=NULL  Else IF(data<tree[data]),insert element(tree(left),data)  Else insert element(tree (right),data) [End of if statement] [End of if statement]  Exit
  • 10.  Check whether node to be searched is greater then or smaller then then the root node and the perform following steps.  If the element to be searched is less than the element present in the root node , traverse the left sub-tree recursively.  If the element to be searched is greater than the element present in root node , traverse the right sub-tree recursively.
  • 11. •Searchelement(tree,val) •If(tree=NULL),then •Write:Tree is empty •If(tree[data]=val),then •Write:search is successful •Else •If(val<tree[data]),then •Searchelement(tree[left],val) •Else( (searchelement (tree[right],val). •[End of if statement] •[End of if statement] •Exit