SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Trees
Kasun Ranga Wijeweera
(Email: krw19870829@gmail.com)
What is a Tree?
• A two dimensional linked structure
• Examples:
– Family tree
– Organization of sports tournament
– Organizational chart of large cooperation
A Tree
• A tree is a nonempty collection of vertices and edges that
satisfies certain requirements
• A vertex is a simple object (also referred to as a node) that can
have a name and carry other associated information
• An edge is a connection between two vertices
• A path in a tree is a list of distinct vertices in which successive
vertices are connected by edges in the tree
• One node in the tree is designated as the root
• The defining property of a tree is that there is exactly one path
between the root and each of the other nodes in the tree
A Sample Tree: Figure 1
Details
• Each node (except the root) has exactly one node above it,
which is called its parent
• The nodes directly below a node are called its children
• In Figure 1, P is the grandchild of R and has three siblings
• Nodes with no children are sometimes called leaves, or
terminal nodes
• Nodes with at least one child are called non terminal nodes
• Sometimes we refer to non terminal nodes as internal nodes
and terminal nodes as external nodes
A Sub Tree
• Any node is the root of a sub tree consisting of it and the nodes
below it
• In Figure 1, there are
– seven one-node sub trees
– one three-node sub tree
– one five-node sub tree
– one six-node sub tree
A Forest
• A set of trees is called a forest
• For example, if we remove the root and the edges connecting it
from the tree in Figure 1, we are left with a forest consisting of
three trees rooted at A, R, and E
An Ordered Tree
• An ordered tree is one in which the order of the children at
every node is specified
• There are many different ways to draw trees that are not
ordered
Levels of a Tree
• The level of a node is the number of nodes on the path from
the node to the root (not including itself)
• For example, in Figure 1, R is on level 1 and S is on level 2
• The height of a tree is the maximum level among all nodes in
the tree (or maximum distance to the root from any node)
• The path length of a tree is the sum of the levels of all the
nodes in the tree (or the sum of the lengths of the paths from
each node to the root)
• The tree in Figure 1 is of height 3 and path length 21
• If internal nodes are distinguished from external nodes, we
speak of internal path length and external path length
A Multi Way Tree
• If each node must have a specific number of children
appearing in a specific order, then we have a multi way tree
• In such a tree, it is appropriate to define special external nodes
which have no children (and usually no name or other
associated information)
• Then external nodes act as “dummy” nodes for reference by
nodes that do not have the specified number of children
A Binary Tree
• A binary tree is an ordered tree consisting of two types of
nodes: external nodes with no children and internal nodes with
exactly two children
• Since the two children of each internal node are ordered, we
refer to the left child and the right child of internal nodes
• Every internal node must have both a left and a right child,
though one or both of them might be an external node
A Sample Binary Tree: Figure 2
Binary Tree Details
• The purpose of the binary tree is to structure the internal
nodes; the external nodes serve only as placeholders
• A binary tree could be “empty”, consisting of no internal
nodes and one external node
Reference
Any Questions?
Thank You!

Weitere ähnliche Inhalte

Was ist angesagt? (19)

Trees
TreesTrees
Trees
 
Trees in data structures
Trees in data structuresTrees in data structures
Trees in data structures
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
Trees
TreesTrees
Trees
 
Farhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructureFarhana shaikh webinar_treesindiscretestructure
Farhana shaikh webinar_treesindiscretestructure
 
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
 
Mca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graphMca iii dfs u-4 tree and graph
Mca iii dfs u-4 tree and graph
 
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
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Tree
TreeTree
Tree
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
 
Tree data structure
Tree data structureTree data structure
Tree data structure
 
Unit – vi tree
Unit – vi   treeUnit – vi   tree
Unit – vi tree
 
Discrete-Chapter 10 Trees
Discrete-Chapter 10 TreesDiscrete-Chapter 10 Trees
Discrete-Chapter 10 Trees
 
Bsc cs ii dfs u-3 tree and graph
Bsc cs  ii dfs u-3 tree and graphBsc cs  ii dfs u-3 tree and graph
Bsc cs ii dfs u-3 tree and graph
 
A binary tree
A binary tree A binary tree
A binary tree
 
Tree
TreeTree
Tree
 
Tree data structure
Tree data structureTree data structure
Tree data structure
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 

Andere mochten auch

Quantifying gurkengradientreview
Quantifying gurkengradientreviewQuantifying gurkengradientreview
Quantifying gurkengradientreviewSchmavidt
 
Linked List Implementation of Stack in C
Linked List Implementation of Stack in CLinked List Implementation of Stack in C
Linked List Implementation of Stack in CKasun Ranga Wijeweera
 
The unix file system
The unix file systemThe unix file system
The unix file systemgsandeepmenon
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked ListSayantan Sur
 
Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems senthilamul
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examplesgreatqadirgee4u
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structurefaran nawaz
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)Trupti Agrawal
 
NFS(Network File System)
NFS(Network File System)NFS(Network File System)
NFS(Network File System)udamale
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 

Andere mochten auch (19)

Graphs Algorithms
Graphs AlgorithmsGraphs Algorithms
Graphs Algorithms
 
Quantifying gurkengradientreview
Quantifying gurkengradientreviewQuantifying gurkengradientreview
Quantifying gurkengradientreview
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Wave ECG
Wave ECGWave ECG
Wave ECG
 
Exhaustive Search
Exhaustive SearchExhaustive Search
Exhaustive Search
 
Ziomi ppt
Ziomi pptZiomi ppt
Ziomi ppt
 
Classification of Algorithms
Classification of AlgorithmsClassification of Algorithms
Classification of Algorithms
 
Linked List Implementation of Stack in C
Linked List Implementation of Stack in CLinked List Implementation of Stack in C
Linked List Implementation of Stack in C
 
The unix file system
The unix file systemThe unix file system
The unix file system
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
 
Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
 
Stacks in algorithems & data structure
Stacks in algorithems & data structureStacks in algorithems & data structure
Stacks in algorithems & data structure
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
NFS(Network File System)
NFS(Network File System)NFS(Network File System)
NFS(Network File System)
 
File management
File managementFile management
File management
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Unix File System
Unix File SystemUnix File System
Unix File System
 
Linked list
Linked listLinked list
Linked list
 

Ähnlich wie Trees krw

Tree Basic concepts of Tree in Data Structure
Tree Basic concepts of Tree in Data StructureTree Basic concepts of Tree in Data Structure
Tree Basic concepts of Tree in Data StructureManoj PAtil
 
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.pptxKALPANAC20
 
Lecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxLecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxfizzaahmed9
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graphRai University
 
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
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of treeRacksaviR
 
tree-160731205832.pptx
tree-160731205832.pptxtree-160731205832.pptx
tree-160731205832.pptxMouDhara1
 

Ähnlich wie Trees krw (20)

Module - 5_Trees.pdf
Module - 5_Trees.pdfModule - 5_Trees.pdf
Module - 5_Trees.pdf
 
Tree Basic concepts of Tree in Data Structure
Tree Basic concepts of Tree in Data StructureTree Basic concepts of Tree in Data Structure
Tree Basic concepts of Tree in Data Structure
 
tree in Data Structures
tree in Data Structurestree in Data Structures
tree in Data Structures
 
Unit 5 Tree.pptx
Unit 5 Tree.pptxUnit 5 Tree.pptx
Unit 5 Tree.pptx
 
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
 
Lecture 5 trees
Lecture 5 treesLecture 5 trees
Lecture 5 trees
 
Lecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptxLecture 21_Trees - I.pptx
Lecture 21_Trees - I.pptx
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
 
Tree 11.ppt
Tree 11.pptTree 11.ppt
Tree 11.ppt
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
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
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Unit III.ppt
Unit III.pptUnit III.ppt
Unit III.ppt
 
tree-160731205832.pptx
tree-160731205832.pptxtree-160731205832.pptx
tree-160731205832.pptx
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
Trees
TreesTrees
Trees
 
Module 8.1 Trees.pdf
Module 8.1 Trees.pdfModule 8.1 Trees.pdf
Module 8.1 Trees.pdf
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 

Mehr von Kasun Ranga Wijeweera

Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonKasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingKasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Kasun Ranga Wijeweera
 

Mehr von Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 

Kürzlich hochgeladen

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Kürzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Trees krw

  • 1. Trees Kasun Ranga Wijeweera (Email: krw19870829@gmail.com)
  • 2. What is a Tree? • A two dimensional linked structure • Examples: – Family tree – Organization of sports tournament – Organizational chart of large cooperation
  • 3. A Tree • A tree is a nonempty collection of vertices and edges that satisfies certain requirements • A vertex is a simple object (also referred to as a node) that can have a name and carry other associated information • An edge is a connection between two vertices • A path in a tree is a list of distinct vertices in which successive vertices are connected by edges in the tree • One node in the tree is designated as the root • The defining property of a tree is that there is exactly one path between the root and each of the other nodes in the tree
  • 4. A Sample Tree: Figure 1
  • 5. Details • Each node (except the root) has exactly one node above it, which is called its parent • The nodes directly below a node are called its children • In Figure 1, P is the grandchild of R and has three siblings • Nodes with no children are sometimes called leaves, or terminal nodes • Nodes with at least one child are called non terminal nodes • Sometimes we refer to non terminal nodes as internal nodes and terminal nodes as external nodes
  • 6. A Sub Tree • Any node is the root of a sub tree consisting of it and the nodes below it • In Figure 1, there are – seven one-node sub trees – one three-node sub tree – one five-node sub tree – one six-node sub tree
  • 7. A Forest • A set of trees is called a forest • For example, if we remove the root and the edges connecting it from the tree in Figure 1, we are left with a forest consisting of three trees rooted at A, R, and E
  • 8. An Ordered Tree • An ordered tree is one in which the order of the children at every node is specified • There are many different ways to draw trees that are not ordered
  • 9. Levels of a Tree • The level of a node is the number of nodes on the path from the node to the root (not including itself) • For example, in Figure 1, R is on level 1 and S is on level 2 • The height of a tree is the maximum level among all nodes in the tree (or maximum distance to the root from any node) • The path length of a tree is the sum of the levels of all the nodes in the tree (or the sum of the lengths of the paths from each node to the root) • The tree in Figure 1 is of height 3 and path length 21 • If internal nodes are distinguished from external nodes, we speak of internal path length and external path length
  • 10. A Multi Way Tree • If each node must have a specific number of children appearing in a specific order, then we have a multi way tree • In such a tree, it is appropriate to define special external nodes which have no children (and usually no name or other associated information) • Then external nodes act as “dummy” nodes for reference by nodes that do not have the specified number of children
  • 11. A Binary Tree • A binary tree is an ordered tree consisting of two types of nodes: external nodes with no children and internal nodes with exactly two children • Since the two children of each internal node are ordered, we refer to the left child and the right child of internal nodes • Every internal node must have both a left and a right child, though one or both of them might be an external node
  • 12. A Sample Binary Tree: Figure 2
  • 13. Binary Tree Details • The purpose of the binary tree is to structure the internal nodes; the external nodes serve only as placeholders • A binary tree could be “empty”, consisting of no internal nodes and one external node