SlideShare a Scribd company logo
TREES
 Tree is a non-linear data structure which
organizes data in a hierarchical structure
and this is a recursive definition. A tree is
a connected graph without any circuits. If
in a graph, there is one and only one path
between every pair of vertices, then
graph is called as a tree.
 Binary tree is a special type of data structure. In
binary tree, every node can have a maximum of 2
children, which are known as Left child and Right
Child. It is a method of placing and locating the
records in a database, especially when all the data
is known to be in random access memory (RAM).
 In computer science, tree traversal (also known as tree
search) is a form of graph traversal and refers to the
process of visiting (checking and/or updating) each
node in a tree data structure, exactly once. Such
traversals are classified by the order in which the nodes
are visited. The following algorithms are described for a
binary tree, but they may be generalized to other trees
as well.
 The idea of threaded binary trees is to make
inorder traversal faster and do it without stack and
without recursion. A binary tree is made threaded
by making all right child pointers that would
normally be NULL point to the inorder successor
of the node (if it exists). There are two types of
threaded binary trees.
 Definition: A way to represent a multiway tree as a binary tree. The
leftmost child, c, of a node, n, in the multiway tree is the left child,
c’, of the corresponding node, n’, in the binary tree. The
immediately right sibling of c is the right child of c’.
 Formal Definition: A multiway tree T can be represented by a
corresponding binary tree B. Let {n1,…, nk} be nodes of the
multiway tree, T. Let {n’1,…, n’k} be nodes of the corresponding
binary tree B. Node nk corresponds to n’k. In particular, nodes nk
and n’k have the same labels and if nk is the root of T, n’k is the
root of B.
 Graph is a data structure that consists of following two components:
 1. A finite set of vertices also called as nodes.
 2. A finite set of ordered pair of the form (u, v) called as edge. The pair is
ordered because (u, v) is not same as (v, u) in case of a directed
graph(di-graph). The pair of the form (u, v) indicates that there is an
edge from vertex u to vertex v. The edges may contain weight/value/cost.
 Graphs are used to represent many real-life applications: Graphs are
used to represent networks. The networks may include paths in a city or
telephone network or circuit network. Graphs are also used in social
networks like linkedIn, Facebook. For example, in Facebook, each
person is represented with a vertex(or node). Each node is a structure
and contains information like person id, name, gender and locale. See
this for more applications of graph.
 Graph traversal is a technique used for
searching a vertex in a graph. The graph
traversal is also used to decide the order
of vertices is visited in the search process.
A graph traversal finds the edges to be
used in the search process without
creating loops.

 A spanning tree is a subset of Graph G, which has
all the vertices covered with minimum possible
number of edges. Hence, a spanning tree does not
have cycles and it cannot be disconnected.
 By this definition, we can draw a conclusion that
every connected and undirected Graph G has at
least one spanning tree. A disconnected graph
does not have any spanning tree, as it cannot be
spanned to all its vertices.
 In graph theory, a component, sometimes called a
connected component, of an undirected graph is a
subgraph in which any two vertices are connected to
each other by paths, and which is connected to no
additional vertices in the supergraph. For example,
the graph shown in the illustration has three
components.
Data structures for single-source shortest paths.
Given an edge-weighted digraph and a designated
vertex s, a shortest-paths tree (SPT) is a subgraph
containing s and all the vertices reachable from s
that forms a directed tree rooted at s such that
every tree path is a shortest path in the digraph
 Transitive closure of a graph. Given a directed graph, find out if a vertex j
is reachable from another vertex i for all vertex pairs (i, j) in the given
graph. ... The reach-ability matrix is called transitive closure of a graph.
 Transitive Closure of a Graph using DFS. Given a directed graph, find out
if a vertex v is reachable from another vertex u for all vertex pairs (u, v) in
the given graph. Here reachable mean that there is a path from vertex u to
v. The reach-ability matrix is called transitive closure of a graph.
 Activity network (activity graph) A graphical
method for showing dependencies between
tasks (activities) in a project. The network
consists of nodes connected by arcs. Nodes
denote events and represent the culmination
of one or more activities.
 Topological Sort. The topological sort algorithm takes
a directed graph and returns an array of the nodes
where each node appears before all the nodes it points
to. The ordering of the nodes in the array is called a
topological ordering. Since node 1 points to nodes 2
and 3, node 1 appears before them in the ordering.
 Critical path is the sequential activities from start to the end of a project.
Although many projects have only one critical path, some projects may
have more than one critical paths depending on the flow logic used in the
project.
 If there is a delay in any of the activities under the critical path, there will
be a delay of the project deliverables.
 Most of the times, if such delay is occurred, project acceleration or re-
sequencing is done in order to achieve the deadlines.

More Related Content

What's hot (20)

PPTX
Dfg & sg ppt (1)
shrutishreya14
 
PDF
BFS & Interval Graph Introduction
nazlitemu
 
PPTX
Graph theory[1]
sethamit
 
PPTX
Finding Deep Structures in Data
Chris Orwa
 
PPTX
Data Applied:Tree Maps
DataminingTools Inc
 
PPT
Distributed Computing Seminar - Lecture 2: MapReduce Theory and Implementation
tugrulh
 
PPTX
R-Trees and Geospatial Data Structures
Amrinder Arora
 
PPT
Trees
Susheel Thakur
 
PPTX
breadth first traversal- tree traversal
AKSHARA V.B
 
PPTX
Logic
Hamxi
 
PPTX
Sparse matrices
Zain Zafar
 
DOC
for sbi so Ds c c++ unix rdbms sql cn os
alisha230390
 
PPTX
Shortest path analysis
A K M Anwaruzzaman
 
PPTX
Intro & Applications of Discrete Math
Bilal Khan
 
DOCX
Dijkstra algorithm
are you
 
PPTX
8. Graph - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
PPT
Introductiont To Aray,Tree,Stack, Queue
Ghaffar Khan
 
PPTX
Dijkstra s algorithm
mansab MIRZA
 
PPTX
Use of the Tree.
Nareender Kumar
 
Dfg & sg ppt (1)
shrutishreya14
 
BFS & Interval Graph Introduction
nazlitemu
 
Graph theory[1]
sethamit
 
Finding Deep Structures in Data
Chris Orwa
 
Data Applied:Tree Maps
DataminingTools Inc
 
Distributed Computing Seminar - Lecture 2: MapReduce Theory and Implementation
tugrulh
 
R-Trees and Geospatial Data Structures
Amrinder Arora
 
breadth first traversal- tree traversal
AKSHARA V.B
 
Logic
Hamxi
 
Sparse matrices
Zain Zafar
 
for sbi so Ds c c++ unix rdbms sql cn os
alisha230390
 
Shortest path analysis
A K M Anwaruzzaman
 
Intro & Applications of Discrete Math
Bilal Khan
 
Dijkstra algorithm
are you
 
8. Graph - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Introductiont To Aray,Tree,Stack, Queue
Ghaffar Khan
 
Dijkstra s algorithm
mansab MIRZA
 
Use of the Tree.
Nareender Kumar
 

Similar to data structures and algorithms Unit 2 (20)

PPTX
Unit ix graph
Tribhuvan University
 
PPTX
Unit 9 graph
Dabbal Singh Mahara
 
PPTX
Graph in data structures
AhsanRazaKolachi
 
PPTX
Lecture 2.3.1 Graph.pptx
king779879
 
PPT
Data Structures-Non Linear DataStructures-Graphs
sailaja156145
 
PPT
Unit VI - Graphs.ppt
HODElex
 
PPTX
Data Structure and algorithms - Graph1.pptx
Kishor767966
 
PPTX
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
 
PPTX
DATA STRUCTURES.pptx
KENNEDY GITHAIGA
 
PDF
Graph Traversals
MaryJacob24
 
PPTX
logic.pptx
KENNEDY GITHAIGA
 
PPTX
Graph data structures for ppt for understanding.pptx
ramkumar649780
 
PPTX
UNIT III.pptx
SwarndeviKm
 
PPTX
Graphs
KomalPaliwal3
 
PPTX
D9-Tree and Graph-Data-Structures information.pptx
naitikchoubey70
 
PPT
Lecture 5b graphs and hashing
Victor Palmar
 
PPTX
Unit 4 dsuc
Sweta Singh
 
PPTX
graphssssssssssssssssssssssssssssss.pptx
FarhanAli766749
 
PPTX
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH
VISWANATHAN R V
 
Unit ix graph
Tribhuvan University
 
Unit 9 graph
Dabbal Singh Mahara
 
Graph in data structures
AhsanRazaKolachi
 
Lecture 2.3.1 Graph.pptx
king779879
 
Data Structures-Non Linear DataStructures-Graphs
sailaja156145
 
Unit VI - Graphs.ppt
HODElex
 
Data Structure and algorithms - Graph1.pptx
Kishor767966
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
 
DATA STRUCTURES.pptx
KENNEDY GITHAIGA
 
Graph Traversals
MaryJacob24
 
logic.pptx
KENNEDY GITHAIGA
 
Graph data structures for ppt for understanding.pptx
ramkumar649780
 
UNIT III.pptx
SwarndeviKm
 
D9-Tree and Graph-Data-Structures information.pptx
naitikchoubey70
 
Lecture 5b graphs and hashing
Victor Palmar
 
Unit 4 dsuc
Sweta Singh
 
graphssssssssssssssssssssssssssssss.pptx
FarhanAli766749
 
UNIT IV NON LINEAR DATA STRUCTURES - GRAPH
VISWANATHAN R V
 
Ad

Recently uploaded (20)

PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PPTX
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
PDF
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
PPTX
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PPTX
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
Aerobic and Anaerobic respiration and CPR.pptx
Olivier Rochester
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
Urban Hierarchy and Service Provisions.pptx
Islamic University of Bangladesh
 
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Ad

data structures and algorithms Unit 2

  • 2.  Tree is a non-linear data structure which organizes data in a hierarchical structure and this is a recursive definition. A tree is a connected graph without any circuits. If in a graph, there is one and only one path between every pair of vertices, then graph is called as a tree.
  • 3.  Binary tree is a special type of data structure. In binary tree, every node can have a maximum of 2 children, which are known as Left child and Right Child. It is a method of placing and locating the records in a database, especially when all the data is known to be in random access memory (RAM).
  • 4.  In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once. Such traversals are classified by the order in which the nodes are visited. The following algorithms are described for a binary tree, but they may be generalized to other trees as well.
  • 5.  The idea of threaded binary trees is to make inorder traversal faster and do it without stack and without recursion. A binary tree is made threaded by making all right child pointers that would normally be NULL point to the inorder successor of the node (if it exists). There are two types of threaded binary trees.
  • 6.  Definition: A way to represent a multiway tree as a binary tree. The leftmost child, c, of a node, n, in the multiway tree is the left child, c’, of the corresponding node, n’, in the binary tree. The immediately right sibling of c is the right child of c’.  Formal Definition: A multiway tree T can be represented by a corresponding binary tree B. Let {n1,…, nk} be nodes of the multiway tree, T. Let {n’1,…, n’k} be nodes of the corresponding binary tree B. Node nk corresponds to n’k. In particular, nodes nk and n’k have the same labels and if nk is the root of T, n’k is the root of B.
  • 7.  Graph is a data structure that consists of following two components:  1. A finite set of vertices also called as nodes.  2. A finite set of ordered pair of the form (u, v) called as edge. The pair is ordered because (u, v) is not same as (v, u) in case of a directed graph(di-graph). The pair of the form (u, v) indicates that there is an edge from vertex u to vertex v. The edges may contain weight/value/cost.  Graphs are used to represent many real-life applications: Graphs are used to represent networks. The networks may include paths in a city or telephone network or circuit network. Graphs are also used in social networks like linkedIn, Facebook. For example, in Facebook, each person is represented with a vertex(or node). Each node is a structure and contains information like person id, name, gender and locale. See this for more applications of graph.
  • 8.  Graph traversal is a technique used for searching a vertex in a graph. The graph traversal is also used to decide the order of vertices is visited in the search process. A graph traversal finds the edges to be used in the search process without creating loops.
  • 9.   A spanning tree is a subset of Graph G, which has all the vertices covered with minimum possible number of edges. Hence, a spanning tree does not have cycles and it cannot be disconnected.  By this definition, we can draw a conclusion that every connected and undirected Graph G has at least one spanning tree. A disconnected graph does not have any spanning tree, as it cannot be spanned to all its vertices.
  • 10.  In graph theory, a component, sometimes called a connected component, of an undirected graph is a subgraph in which any two vertices are connected to each other by paths, and which is connected to no additional vertices in the supergraph. For example, the graph shown in the illustration has three components.
  • 11. Data structures for single-source shortest paths. Given an edge-weighted digraph and a designated vertex s, a shortest-paths tree (SPT) is a subgraph containing s and all the vertices reachable from s that forms a directed tree rooted at s such that every tree path is a shortest path in the digraph
  • 12.  Transitive closure of a graph. Given a directed graph, find out if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. ... The reach-ability matrix is called transitive closure of a graph.  Transitive Closure of a Graph using DFS. Given a directed graph, find out if a vertex v is reachable from another vertex u for all vertex pairs (u, v) in the given graph. Here reachable mean that there is a path from vertex u to v. The reach-ability matrix is called transitive closure of a graph.
  • 13.  Activity network (activity graph) A graphical method for showing dependencies between tasks (activities) in a project. The network consists of nodes connected by arcs. Nodes denote events and represent the culmination of one or more activities.
  • 14.  Topological Sort. The topological sort algorithm takes a directed graph and returns an array of the nodes where each node appears before all the nodes it points to. The ordering of the nodes in the array is called a topological ordering. Since node 1 points to nodes 2 and 3, node 1 appears before them in the ordering.
  • 15.  Critical path is the sequential activities from start to the end of a project. Although many projects have only one critical path, some projects may have more than one critical paths depending on the flow logic used in the project.  If there is a delay in any of the activities under the critical path, there will be a delay of the project deliverables.  Most of the times, if such delay is occurred, project acceleration or re- sequencing is done in order to achieve the deadlines.