SlideShare a Scribd company logo
1 of 13
Tree
• A Tree definition in data structure is a tree is a
hierarchical data structure. It consists of multiple
nodes that contain the actual data. The node that
is at the top of the hierarchy is called the root
node of a tree.
Basic terminologies or Building Blocks
• Root node : The root node is the topmost node in the tree hierarchy. In
other words, the root node is the one that doesn't have any parent. In the
above structure, node numbered 1 is the root node of the tree. If a node
is directly linked to some other node, it would be called a parent-child
relationship.
• Parent: If the node contains any sub-node, then that node is said to be the
parent of that sub-node.
• Child node: If the node is a descendant of any node, then the node is
known as a child node.
Basic terminologies or Building Blocks
• Leaf Node:- The node of the tree, which doesn't have any child node, is called a
leaf node. A leaf node is the bottom-most node of the tree. There can be any
number of leaf nodes present in a general tree. Leaf nodes can also be called
external nodes.
• Sibling: The nodes that have the same parent are known as siblings.
• Internal nodes: A node has atleast one child node known as an internal Nodes
• Ancestor node:- An ancestor of a node is any predecessor
node on a path from the root to that node. The root node
doesn't have any ancestors. In the tree shown in the above
image, nodes 1, 2, and 5 are the ancestors of node 10.
• Descendant: The immediate successor of the given node is
known as a descendant of a node. In the above figure, 10 is
the descendant of node 5.
• Number of edges: If there are n nodes, then there
would n-1 edges. Each arrow in the structure
represents the link or path.
• Each node, except the root node, will have atleast one
incoming link known as an edge. There would be one
link for the parent-child relationship.
• Depth of node x: The depth of node x can be defined
as the length of the path from the root to the node x.
• So, the depth of node x can also be defined as the
number of edges between the root node and the node
x. The root node has 0 depth.
• Height of node x: The height of node x can be defined
as the longest path from the node x to the leaf node.
Types of Tree data structure
• General tree
• In a general tree, every node can have any number of children.
• Binary Tree
• A binary tree is a special type of tree data structure in which every
node can have a maximum of 2 children.
• One is known as a left child and the other is known as right child.
General tree Binary Tree
Types of Binary Tree:
• Full Binary Tree
• Perfect Binary Tree
• Degenerate Binary Tree
• Skewed Binary Trees
Full Binary Tree / Strictly Binary Tree
• In a binary tree, every node can have a maximum of two children.
• But in strictly binary tree, every node should have exactly two
children or none.
• A binary tree in which every node has either two or zero number
of children is called Strictly Binary Tree
•
Full Binary Tree ?? Full Binary Tree ??
Perfect / Complete Binary Tree
• Each Node has exactly 2 Nodes and all leaf
nodes must be at the same level
Perfect Binary Tree??
Perfect Binary Tree??
Almost Complete Binary Tree
• A tree in which all levels are completely filled
except possibly for the last level. it is a binary
tree that is filled from left to right across each
level.
Skewed Binary Tree
• A skewed binary tree is a tree in which the tree is
either dominated by the left nodes or the right
nodes.
• Thus, there are two types of skewed binary tree:
left-skewed binary tree and right-skewed binary
tree.
• The tree data structure can be created by
creating the nodes dynamically with the help
of the pointers. The tree in the memory can
be represented as shown below:

More Related Content

Similar to Tree Basic concepts of Tree in Data Structure

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
 
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
 
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
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of treeRacksaviR
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap treezia eagle
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsBHARATH KUMAR
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdfMaryJacob24
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptxAbirami A
 

Similar to Tree Basic concepts of Tree in Data Structure (20)

Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
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
 
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.pptx
Tree.pptxTree.pptx
Tree.pptx
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 
Tree
TreeTree
Tree
 
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
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Trees krw
Trees krwTrees krw
Trees krw
 
Search tree,Tree and binary tree and heap tree
Search tree,Tree  and binary tree and heap treeSearch tree,Tree  and binary tree and heap tree
Search tree,Tree and binary tree and heap tree
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
 
Tree
TreeTree
Tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Unit III.ppt
Unit III.pptUnit III.ppt
Unit III.ppt
 
tree traversals.pdf
tree traversals.pdftree traversals.pdf
tree traversals.pdf
 
Binary tree
Binary treeBinary tree
Binary tree
 
Lecture 5 trees
Lecture 5 treesLecture 5 trees
Lecture 5 trees
 
Tree
TreeTree
Tree
 
Tree
TreeTree
Tree
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 

Tree Basic concepts of Tree in Data Structure

  • 1.
  • 2. Tree • A Tree definition in data structure is a tree is a hierarchical data structure. It consists of multiple nodes that contain the actual data. The node that is at the top of the hierarchy is called the root node of a tree.
  • 3. Basic terminologies or Building Blocks • Root node : The root node is the topmost node in the tree hierarchy. In other words, the root node is the one that doesn't have any parent. In the above structure, node numbered 1 is the root node of the tree. If a node is directly linked to some other node, it would be called a parent-child relationship. • Parent: If the node contains any sub-node, then that node is said to be the parent of that sub-node. • Child node: If the node is a descendant of any node, then the node is known as a child node.
  • 4. Basic terminologies or Building Blocks • Leaf Node:- The node of the tree, which doesn't have any child node, is called a leaf node. A leaf node is the bottom-most node of the tree. There can be any number of leaf nodes present in a general tree. Leaf nodes can also be called external nodes. • Sibling: The nodes that have the same parent are known as siblings. • Internal nodes: A node has atleast one child node known as an internal Nodes
  • 5. • Ancestor node:- An ancestor of a node is any predecessor node on a path from the root to that node. The root node doesn't have any ancestors. In the tree shown in the above image, nodes 1, 2, and 5 are the ancestors of node 10. • Descendant: The immediate successor of the given node is known as a descendant of a node. In the above figure, 10 is the descendant of node 5.
  • 6. • Number of edges: If there are n nodes, then there would n-1 edges. Each arrow in the structure represents the link or path. • Each node, except the root node, will have atleast one incoming link known as an edge. There would be one link for the parent-child relationship. • Depth of node x: The depth of node x can be defined as the length of the path from the root to the node x. • So, the depth of node x can also be defined as the number of edges between the root node and the node x. The root node has 0 depth. • Height of node x: The height of node x can be defined as the longest path from the node x to the leaf node.
  • 7. Types of Tree data structure • General tree • In a general tree, every node can have any number of children. • Binary Tree • A binary tree is a special type of tree data structure in which every node can have a maximum of 2 children. • One is known as a left child and the other is known as right child. General tree Binary Tree
  • 8. Types of Binary Tree: • Full Binary Tree • Perfect Binary Tree • Degenerate Binary Tree • Skewed Binary Trees
  • 9. Full Binary Tree / Strictly Binary Tree • In a binary tree, every node can have a maximum of two children. • But in strictly binary tree, every node should have exactly two children or none. • A binary tree in which every node has either two or zero number of children is called Strictly Binary Tree • Full Binary Tree ?? Full Binary Tree ??
  • 10. Perfect / Complete Binary Tree • Each Node has exactly 2 Nodes and all leaf nodes must be at the same level Perfect Binary Tree?? Perfect Binary Tree??
  • 11. Almost Complete Binary Tree • A tree in which all levels are completely filled except possibly for the last level. it is a binary tree that is filled from left to right across each level.
  • 12. Skewed Binary Tree • A skewed binary tree is a tree in which the tree is either dominated by the left nodes or the right nodes. • Thus, there are two types of skewed binary tree: left-skewed binary tree and right-skewed binary tree.
  • 13. • The tree data structure can be created by creating the nodes dynamically with the help of the pointers. The tree in the memory can be represented as shown below: