SlideShare a Scribd company logo
1 of 23
INTRODUCTION 
Tree is a non-linear data structure. 
It is mainly used to represent data 
containing a hierarchical 
relationship between elements. 
Eg: Government Subdivisions.
TREE TERMINOLOGIES 
ROOT: Node at the top of the tree is called as root. 
There is only one root in a tree. 
PARENT: Any node(except the root) has exactly one 
edge running upward to another node. The node 
above the given node is called parent. 
CHILD: Any node may have one or more lines running 
downward to other nodes. The nodes below a given 
node are called its children.
ANCESTOR: Parents, grandparents are called 
ancestors 
DESCENDANTS: Children, grandchildren are called 
descendants. 
SIBLINGS: Children of the same parent are called 
siblings. 
LEVEL: The level of a particular node refers to how 
many generations the node is from the root. If the root 
is assumed to be on level ‘0’ then its children are at 
level ‘1’. 
DEPTH: The Depth of a node ‘n’ is the length of the 
unique path from root to node ‘n’. The root is at depth 
‘0’.
LEAF NODE: Node having no children. 
HEIGHT: Height of a node ‘n’ is the length of the 
longest path from node ‘n’ to leaf. 
Height of the tree= Height of the root. 
DEGREE OF THE NODE: Degree of the node is the 
number of children of the node. 
The node with degree ‘0’ is a leaf or terminal 
node. 
Degree of tree= Maximum degree of any node in the 
tree.
BINARY TREES 
The Binary Tree is a tree in which no node 
can have more than two children. 
PROPERTIES: 
Every Binary tree with ‘n’ elements, 
n>0 has exactly n-1 edges. 
A full binary tree of height ‘h’ has 
exactly 2^(h+1) -1 nodes.
BINARY TREE TRAVERSAL METHOD: 
Traversal is the process of visiting every 
node in the tree exactly once. There are three methods 
of Traversal. 
Pre order. 
In order. 
Post order.
PRE ORDER: 
Step 1: Visit the root. 
Step 2: Traverse the left sub tree. 
Step 3: Traverse the right sub tree. 
IN ORDER: 
Step 1: Traverse the left sub tree. 
Step 2: Visit the root. 
Step 3: Traverse the right sub tree. 
POST ORDER: 
Step 1: Traverse the left sub tree. 
Step 2: Traverse the right sub tree. 
Step 3: Visit the root.
EXPRESSION TREE 
CONVERSION OF POSTFIX EXPRESSION INTO 
EXPRESSION TREE: 
Step 1: Read the postfix expression one symbol at a time 
from left to right. 
Step 2: If the symbol is an operand, we create a one node 
tree and push a pointer to it on to a stack. 
Step 3: If the symbol is an operator pop the last two sub 
trees and forma new tree whose root is that operator.
Eg: ab+cde+**
CONVERSION OF PREFIX EXPRESSION TO 
EXPRESSION TREE: 
Step 1:Read the prefix expression from right to left. 
Step 2: same as previous one. 
Step 3: same as previous one. Additionally, the last 
popped one should be on the left of the root.
Eg: ++a*bc*+*defg
BINARY SEARCH TREE 
Binary Search Tree is a tree in which for every 
node X, in the tree, the values of all the keys in its left 
sub tree are smaller than the key value in X, and the 
values of all the keys in its right sub tree are larger than 
the key value in X. 
Left Sub tree should have lesser value than its 
corresponding root and also the main root. Whereas 
Right Sub tree should have greater value than the root.
INSERTION:
DELETION:
THANK YOU!!

More Related Content

Viewers also liked (20)

Lect 10 Zaheer Abbas
Lect 10 Zaheer AbbasLect 10 Zaheer Abbas
Lect 10 Zaheer Abbas
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
 
Lect 13 Zaheer Abbas
Lect 13 Zaheer AbbasLect 13 Zaheer Abbas
Lect 13 Zaheer Abbas
 
Lect 1-2 Zaheer Abbas
Lect 1-2 Zaheer AbbasLect 1-2 Zaheer Abbas
Lect 1-2 Zaheer Abbas
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
Lect 22 Zaheer Abbas
Lect 22 Zaheer AbbasLect 22 Zaheer Abbas
Lect 22 Zaheer Abbas
 
Lect 21 Zaheer Abbas
Lect 21 Zaheer AbbasLect 21 Zaheer Abbas
Lect 21 Zaheer Abbas
 
It3 4 by Zaheer Abbas Aghani
It3 4 by Zaheer Abbas AghaniIt3 4 by Zaheer Abbas Aghani
It3 4 by Zaheer Abbas Aghani
 
Telecommunication
TelecommunicationTelecommunication
Telecommunication
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
 
REVIEW PAPER on Scheduling in Cloud Computing
REVIEW PAPER on Scheduling in Cloud ComputingREVIEW PAPER on Scheduling in Cloud Computing
REVIEW PAPER on Scheduling in Cloud Computing
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of tree
 
What Is Internet made by Ms. Archika Bhatia
What Is Internet made by Ms. Archika BhatiaWhat Is Internet made by Ms. Archika Bhatia
What Is Internet made by Ms. Archika Bhatia
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphs
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 
Sorting
SortingSorting
Sorting
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
 

Similar to Trees

Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptxAbirami A
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxRajitha Reddy Alugati
 
tree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxtree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxRupaRaj6
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2smruti sarangi
 
Describe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docxDescribe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docxandyb37
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationnakulvarshney371
 
trees in data structure
trees in data structure trees in data structure
trees in data structure shameen khan
 
Binary tree in data structures
Binary tree in  data structuresBinary tree in  data structures
Binary tree in data structureschauhankapil
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10sumitbardhan
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdfMaryJacob24
 

Similar to Trees (20)

Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
TREES34.pptx
TREES34.pptxTREES34.pptx
TREES34.pptx
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Trees
TreesTrees
Trees
 
tree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxtree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptx
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
 
Describe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docxDescribe the tree data structure- What is a root node- What is a child.docx
Describe the tree data structure- What is a root node- What is a child.docx
 
Binary tree traversal ppt - 02.03.2020
Binary tree traversal   ppt - 02.03.2020Binary tree traversal   ppt - 02.03.2020
Binary tree traversal ppt - 02.03.2020
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentation
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Binary tree in data structures
Binary tree in  data structuresBinary tree in  data structures
Binary tree in data structures
 
Tree
TreeTree
Tree
 
Trees
TreesTrees
Trees
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdf
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 

Recently uploaded

History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationEmaan Sharma
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024EMMANUELLEFRANCEHELI
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Toolssoginsider
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/FootingEr. Suman Jyoti
 
Databricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdfDatabricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdfVinayVadlagattu
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdfVinayVadlagattu
 
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...mikehavy0
 
Introduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptxIntroduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptxProfASKolap
 
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书c3384a92eb32
 
DBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptxDBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptxrajjais1221
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxMustafa Ahmed
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfJNTUA
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptamrabdallah9
 

Recently uploaded (20)

History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
Databricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdfDatabricks Generative AI FoundationCertified.pdf
Databricks Generative AI FoundationCertified.pdf
 
Databricks Generative AI Fundamentals .pdf
Databricks Generative AI Fundamentals  .pdfDatabricks Generative AI Fundamentals  .pdf
Databricks Generative AI Fundamentals .pdf
 
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
 
Introduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptxIntroduction-to- Metrology and Quality.pptx
Introduction-to- Metrology and Quality.pptx
 
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
一比一原版(Griffith毕业证书)格里菲斯大学毕业证成绩单学位证书
 
DBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptxDBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptx
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 

Trees

  • 1.
  • 2. INTRODUCTION Tree is a non-linear data structure. It is mainly used to represent data containing a hierarchical relationship between elements. Eg: Government Subdivisions.
  • 3.
  • 4. TREE TERMINOLOGIES ROOT: Node at the top of the tree is called as root. There is only one root in a tree. PARENT: Any node(except the root) has exactly one edge running upward to another node. The node above the given node is called parent. CHILD: Any node may have one or more lines running downward to other nodes. The nodes below a given node are called its children.
  • 5. ANCESTOR: Parents, grandparents are called ancestors DESCENDANTS: Children, grandchildren are called descendants. SIBLINGS: Children of the same parent are called siblings. LEVEL: The level of a particular node refers to how many generations the node is from the root. If the root is assumed to be on level ‘0’ then its children are at level ‘1’. DEPTH: The Depth of a node ‘n’ is the length of the unique path from root to node ‘n’. The root is at depth ‘0’.
  • 6. LEAF NODE: Node having no children. HEIGHT: Height of a node ‘n’ is the length of the longest path from node ‘n’ to leaf. Height of the tree= Height of the root. DEGREE OF THE NODE: Degree of the node is the number of children of the node. The node with degree ‘0’ is a leaf or terminal node. Degree of tree= Maximum degree of any node in the tree.
  • 7. BINARY TREES The Binary Tree is a tree in which no node can have more than two children. PROPERTIES: Every Binary tree with ‘n’ elements, n>0 has exactly n-1 edges. A full binary tree of height ‘h’ has exactly 2^(h+1) -1 nodes.
  • 8. BINARY TREE TRAVERSAL METHOD: Traversal is the process of visiting every node in the tree exactly once. There are three methods of Traversal. Pre order. In order. Post order.
  • 9. PRE ORDER: Step 1: Visit the root. Step 2: Traverse the left sub tree. Step 3: Traverse the right sub tree. IN ORDER: Step 1: Traverse the left sub tree. Step 2: Visit the root. Step 3: Traverse the right sub tree. POST ORDER: Step 1: Traverse the left sub tree. Step 2: Traverse the right sub tree. Step 3: Visit the root.
  • 10. EXPRESSION TREE CONVERSION OF POSTFIX EXPRESSION INTO EXPRESSION TREE: Step 1: Read the postfix expression one symbol at a time from left to right. Step 2: If the symbol is an operand, we create a one node tree and push a pointer to it on to a stack. Step 3: If the symbol is an operator pop the last two sub trees and forma new tree whose root is that operator.
  • 12.
  • 13. CONVERSION OF PREFIX EXPRESSION TO EXPRESSION TREE: Step 1:Read the prefix expression from right to left. Step 2: same as previous one. Step 3: same as previous one. Additionally, the last popped one should be on the left of the root.
  • 15.
  • 16.
  • 17.
  • 18. BINARY SEARCH TREE Binary Search Tree is a tree in which for every node X, in the tree, the values of all the keys in its left sub tree are smaller than the key value in X, and the values of all the keys in its right sub tree are larger than the key value in X. Left Sub tree should have lesser value than its corresponding root and also the main root. Whereas Right Sub tree should have greater value than the root.
  • 19.
  • 22.