SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
What is a Tree
Figure: fig1.
• A data structure similar to linked list.
• Each node points many other.
• Hierarchical nature in graphical form.
Features and types
• Root - node with no parent.
• Edge - link from parent to child.
• Leaf node - node with no child.
• Siblings - children of same parent.
• node p is an ancestor of node q if on path from root to q p
appears.
Figure: fig2.
conti.
• Level-set of nodes at a given depth (root-0)
Figure: fig3.
• Depth - length of path from rooot to node.
• Height - length of path from node to the deepest node.
• Height of tree - Maximum of all heights.
• Depth of tree - Maximum of all depths.
conti.
Conti.
• Size - Number of descendants including itself.
• Skew Trees - Every node in tree has one child.
a. Left Skew tree - only left child.
b. Right Skew tree - only right child.
Figure: fig4.
About Binary Trees
• Binary Tree
Binary tree -ro,one or two children. Essentially root and two
disjoint binary trees .
Figure: fig5.
Types Of Binary Trees
• Types of Binary Trees
1. Strict Binary Tree - Each node exactly two or no children.
Figure: fig6.
1. Full Binary Tree - Each node 2 children, all leaf nodes same
level.
Figure: fig6.2.
1. Complete Binary Tree - every level, except possibly the last, is
completely filled, and all nodes are as far left as possible..
Properties of Binary Trees
Figure: fig7.1.
Figure: fig7.2.
Infering from table
• Conti
We infer:
• No. of nodes = 2h+1 − 1.
• No. of nodes in complete tree are greater than 2h (min.) and
2h+1 − 1(max.)
• No. of leaf nodes in a full binary tree = 2h
• No. of NULL pointers in a complete tree = n + 1(n - total
nodes)
Structure of Binary Tree
• Structure of Binary Tree
Figure: fig8.
struct BinaryTreeNode
{
int data;
struct BinaryTreeNode* left;
struct BinaryTreeNode* right;
};
Operations on Binary Trees
• Operations on Binary Trees
Basic Operations
* Inserting an element into tree.
* Deleting an element from tree.
* Searching for an element.
* traversing the tree.
Auxiliary Operations
* Finding size of the tree.
* Finding height of tree.
* Finding the level which has maximum sum.
* Finding least common ancestor(LCA).
applications
• Applicatons of Binary Tree
• Expression trees - used in compilers.
• Huffman coding trees - used in data compression algorithms.
• Binary Search Trees - support search,insertion and deletion in
O(logn) (average).
• Priority Queues - support search and deletion in logarithmic
time(worst case).
End

Mais conteúdo relacionado

Destaque

resume t2k.docx2 no adress
resume t2k.docx2 no adressresume t2k.docx2 no adress
resume t2k.docx2 no adress
Tania Lucero
 
Do Property Managers Handle Everything?
Do Property Managers Handle Everything?Do Property Managers Handle Everything?
Do Property Managers Handle Everything?
btotheba
 
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUMCyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
Marek Cynowski
 
Stages of Skill Acquisition
Stages of Skill AcquisitionStages of Skill Acquisition
Stages of Skill Acquisition
lexxiiyoung
 
4Developers - Wdrożenie e-commerce w branży fashion
4Developers - Wdrożenie e-commerce w branży fashion4Developers - Wdrożenie e-commerce w branży fashion
4Developers - Wdrożenie e-commerce w branży fashion
Marcin Cichoń
 

Destaque (13)

The Marketing Equation - Infographic
The Marketing Equation - InfographicThe Marketing Equation - Infographic
The Marketing Equation - Infographic
 
resume t2k.docx2 no adress
resume t2k.docx2 no adressresume t2k.docx2 no adress
resume t2k.docx2 no adress
 
Do Property Managers Handle Everything?
Do Property Managers Handle Everything?Do Property Managers Handle Everything?
Do Property Managers Handle Everything?
 
Terry brival bio
Terry brival bioTerry brival bio
Terry brival bio
 
Scuba Diving (Enhancing private and professional skills)
Scuba Diving (Enhancing private and professional skills)Scuba Diving (Enhancing private and professional skills)
Scuba Diving (Enhancing private and professional skills)
 
Linked List
Linked ListLinked List
Linked List
 
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUMCyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
Cyfrowa strategia w świecie omnichannel - Marek Cynowski - IAB FORUM
 
Stages of Skill Acquisition
Stages of Skill AcquisitionStages of Skill Acquisition
Stages of Skill Acquisition
 
4Developers - Wdrożenie e-commerce w branży fashion
4Developers - Wdrożenie e-commerce w branży fashion4Developers - Wdrożenie e-commerce w branży fashion
4Developers - Wdrożenie e-commerce w branży fashion
 
Belajar dan pembelajaran
Belajar dan pembelajaranBelajar dan pembelajaran
Belajar dan pembelajaran
 
Satyam Scam & Corporate Governance
Satyam Scam & Corporate GovernanceSatyam Scam & Corporate Governance
Satyam Scam & Corporate Governance
 
Understanding HUMAN RESOURCE DEVELOPMENT (HRD)
Understanding HUMAN RESOURCE DEVELOPMENT (HRD)Understanding HUMAN RESOURCE DEVELOPMENT (HRD)
Understanding HUMAN RESOURCE DEVELOPMENT (HRD)
 
Happy & sad
Happy & sadHappy & sad
Happy & sad
 

Semelhante a 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
nakulvarshney371
 
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptxTERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
KALPANAC20
 

Semelhante a Trees (20)

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
 
Module - 5_Trees.pdf
Module - 5_Trees.pdfModule - 5_Trees.pdf
Module - 5_Trees.pdf
 
Lec20
Lec20Lec20
Lec20
 
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
 
Tree
TreeTree
Tree
 
Heap Data Structure
 Heap Data Structure Heap Data Structure
Heap Data Structure
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 
Introduction to tree ds
Introduction to tree dsIntroduction to tree ds
Introduction to tree ds
 
Binary tree
Binary treeBinary tree
Binary tree
 
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
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
 
Unit iii(dsc++)
Unit iii(dsc++)Unit iii(dsc++)
Unit iii(dsc++)
 
Lecture 9: Binary tree basics
Lecture 9: Binary tree basicsLecture 9: Binary tree basics
Lecture 9: Binary tree basics
 
Unit 4.1 (tree)
Unit 4.1 (tree)Unit 4.1 (tree)
Unit 4.1 (tree)
 
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptxTERMINOLOGIES OF TREE, TYPES OF TREE.pptx
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
 
Unit 5 Tree.pptx
Unit 5 Tree.pptxUnit 5 Tree.pptx
Unit 5 Tree.pptx
 

Mais de Shivam Singh (6)

Stacks
StacksStacks
Stacks
 
What If Microsoft sold diapers!? MS Diapers!
What If Microsoft sold diapers!? MS Diapers!What If Microsoft sold diapers!? MS Diapers!
What If Microsoft sold diapers!? MS Diapers!
 
Search Algprithms
Search AlgprithmsSearch Algprithms
Search Algprithms
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 

Último

scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 

Trees

  • 1. What is a Tree Figure: fig1. • A data structure similar to linked list. • Each node points many other. • Hierarchical nature in graphical form.
  • 2. Features and types • Root - node with no parent. • Edge - link from parent to child. • Leaf node - node with no child. • Siblings - children of same parent. • node p is an ancestor of node q if on path from root to q p appears. Figure: fig2.
  • 3. conti. • Level-set of nodes at a given depth (root-0) Figure: fig3. • Depth - length of path from rooot to node. • Height - length of path from node to the deepest node. • Height of tree - Maximum of all heights. • Depth of tree - Maximum of all depths.
  • 4. conti. Conti. • Size - Number of descendants including itself. • Skew Trees - Every node in tree has one child. a. Left Skew tree - only left child. b. Right Skew tree - only right child. Figure: fig4.
  • 5. About Binary Trees • Binary Tree Binary tree -ro,one or two children. Essentially root and two disjoint binary trees . Figure: fig5.
  • 6. Types Of Binary Trees • Types of Binary Trees 1. Strict Binary Tree - Each node exactly two or no children. Figure: fig6. 1. Full Binary Tree - Each node 2 children, all leaf nodes same level. Figure: fig6.2. 1. Complete Binary Tree - every level, except possibly the last, is completely filled, and all nodes are as far left as possible..
  • 7. Properties of Binary Trees Figure: fig7.1. Figure: fig7.2.
  • 8. Infering from table • Conti We infer: • No. of nodes = 2h+1 − 1. • No. of nodes in complete tree are greater than 2h (min.) and 2h+1 − 1(max.) • No. of leaf nodes in a full binary tree = 2h • No. of NULL pointers in a complete tree = n + 1(n - total nodes)
  • 9. Structure of Binary Tree • Structure of Binary Tree Figure: fig8. struct BinaryTreeNode { int data; struct BinaryTreeNode* left; struct BinaryTreeNode* right; };
  • 10. Operations on Binary Trees • Operations on Binary Trees Basic Operations * Inserting an element into tree. * Deleting an element from tree. * Searching for an element. * traversing the tree. Auxiliary Operations * Finding size of the tree. * Finding height of tree. * Finding the level which has maximum sum. * Finding least common ancestor(LCA).
  • 11. applications • Applicatons of Binary Tree • Expression trees - used in compilers. • Huffman coding trees - used in data compression algorithms. • Binary Search Trees - support search,insertion and deletion in O(logn) (average). • Priority Queues - support search and deletion in logarithmic time(worst case).
  • 12. End