SlideShare a Scribd company logo
6
Most read
9
Most read
11
Most read
Course: BCA-II
Subject: Data Structure
Unit-3
Tree and Graph
NONLINEAR DATA STRUCTURE
 2 primary types:
• Trees
• Graphs
• All trees are graphs, but not all graphs are trees
• Recursion is useful and is the easiest way to process
them.
• It helps keep track of what's been processed and what
remains
Graphs
•Graphs can have multiple references in and multiple references out
(whereas tree node only has one reference in)
•Graphs can be directed or undirected and cyclic or acyclic
Trees
• Single parent
• 0 or more children
• A node with no children is called a "leaf"
• The topmost node is called the "root"
• N-ary trees
• Binary trees
N-ary Trees
 The best example of an n-ary tree is your computer’s
directory system.
 It has a single starting point and then 0 or more
branches.
Binary Trees and Binary Search Trees
• Binary search trees allow for fast insertion and removal of
elements
• They are specially designed for fast searching
• A binary tree consists of two nodes, each of which has two
child nodes
• All nodes in a binary search tree fulfill the property that:
• Descendants to the left have smaller data values than the node
data value
• Descendants to the right have larger data values than the node
data value
BST Tree Nodes
• All nodes in a binary search tree fulfill the property that:
• Descendants to the left have smaller data values than
the node data value
• Descendants to the right have larger data values than the
node data value
BST (Balanced Binary Trees)
• Balanced tree: each node has approximately as many
descendants on the left as on the right
• If a binary search tree is balanced, then adding an
element takes O(log(n)) time
• If the tree is unbalanced, insertion can be slow
• Perhaps as slow as insertion into a linked list
Traversing a Tree
 Which were used for the binary tree can now be used for the
general.
 When the general tree has been represented as a binary tree, the
algorithms l tree.
 In-order traversals make no sense when a general tree is converted
to a binary tree.
 In the general tree each node can have more than two children so
trying to insert the parent node in between the children is rather
difficult, especially if there is an odd number of children.
 Pre - order
 This is a process where the root is accessed and processed and
then each of the subtrees is preorder processed. It is also called a
depth-first traversal.
Traversing a Tree
 Pre-order Traversal
 In this way the resulting printout has all nodes at any given
level starting in the same tab column.
 It is relatively easy to draw lines to produce the original
general tree except that the tree is on its side with it's root at the
left rather than with the root at the top.
Tree Traversal
• Tree traversal schemes include
• Preorder traversal (root, left, right)
• Inorder traversal (left, root, right)
• Postorder traversal ( left, right, root)
• Preorder generates prefix expression,(polish notation) from
an expression trees
• Inorder generates a sorted ordering
• Postorder generates a post fix expression, also useful for
node deletion
Height of a BST
 Insert 7
 Insert 4
 Insert 1
 Insert 9
 Insert 5
 It’s a complete tree!
7
4 9
1 5
height = log(5)+1 =
3
BSTs with heights O(log n)
 It would be ideal if a BST was always close to a full
binary tree
 It’s enough to guarantee that the height of tree is
O(log n)
 To guarantee that we have to make the structure of the
tree and insertion and deletion algorithms more
complex
 e.g. AVL trees (balanced), 2-3 trees, 2-3-4 trees (full
but not binary), red–black trees (if red vertices are
ignored then it’s like a full tree)
What is a graph?
 A data structure that consists of a set of nodes
(vertices) and a set of edges that relate the nodes to
each other
 The set of edges describes relationships among the
vertices
Formal definition of graphs
 A graph G is defined as follows:
G=(V,E)
V(G): a finite, nonempty set of vertices
E(G): a set of edges (pairs of vertices)
Directed vs. undirected graphs (cont.)
 When the edges in a graph have a direction, the
graph is called directed (or digraph)
 When the edges in a graph have no direction, the
graph is called undirected.
 Warning: if the graph is directed, the order of the
vertices in each edge is important !!
Breadth-first searching[1]
 A breadth-first search (BFS)
explores nodes nearest the root
before exploring nodes further
away
 For example, after searching A,
then B, then C, the search
proceeds with D, E, F, G
 Node are explored in the order
A B C D E F G H I J K L M N O P Q
 J will be found before N
L M N O P
G
Q
H JI K
FED
B C
A
Depth-first searching[2]
 A depth-first search (DFS)
explores a path all the way to a
leaf before backtracking and
exploring another path
 For example, after searching A,
then B, then D, the search
backtracks and tries another path
from B
 Node are explored in the order A
B D E H L M N I O P C F G J K
Q
 N will be found before JL M N O P
G
Q
H JI K
FED
B C
A
A spanning tree of a graph is just a subgraph that
contains all the vertices and is a tree.
A graph may have many spanning trees.
o
r
o
r
o
r
Some Spanning Trees from Graph AGraph
A
Spanning Trees
Minimum Spanning Trees
The Minimum Spanning Tree for a given graph is the
Spanning Tree of minimum cost for that graph.
5
7
2
1
3
4
2
1
3
Complete Graph Minimum Spanning Tree
References
 An introduction to Datastructure with application by jean Trembley and sorrenson
 Data structures by schaums and series –seymour lipschutz
 http://en.wikipedia.org/wiki/Book:Data_structures
 http://www.amazon.com/Data-Structures-Algorithms
 http://www.amazon.in/Data-Structures-Algorithms-Made-Easy/dp/0615459811/
 http://www.amazon.in/Data-Structures-SIE-Seymour-Lipschutz/dp
 List of Images
1. http://www.algolist.net/Algorithms/Graph/Undirected/breadth-first_search
2. http://www.expertsmind.com/questions/depth-first-search-30153061.aspx

More Related Content

What's hot (20)

PPTX
Different types of Linked list.
JAYANTA OJHA
 
PPTX
Trees (data structure)
Trupti Agrawal
 
PPTX
Threaded Binary Tree
khabbab_h
 
PPT
DATA STRUCTURES
bca2010
 
PDF
Array data structure
maamir farooq
 
PPTX
Set data structure
Tech_MX
 
PPTX
Asymptotic notations
Nikhil Sharma
 
PPTX
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
PPT
C++ Data Structure PPT.ppt
Mukesh Thakur
 
PDF
Binary search tree operations
Kamran Zafar
 
PPT
image processing intensity transformation
alobaidimki
 
PPT
Binary search tree in data structures
chauhankapil
 
PPT
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
PDF
Binary tree
Rajendran
 
PPTX
Tree and graph
Muhaiminul Islam
 
PDF
Cursors in MySQL
Tharindu Weerasinghe
 
PDF
M.c.qs -1(number systems)
Nadeem Uddin
 
PDF
Red black tree
Dr Sandeep Kumar Poonia
 
PPT
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
PPTX
Data structures - unit 1
SaranyaP45
 
Different types of Linked list.
JAYANTA OJHA
 
Trees (data structure)
Trupti Agrawal
 
Threaded Binary Tree
khabbab_h
 
DATA STRUCTURES
bca2010
 
Array data structure
maamir farooq
 
Set data structure
Tech_MX
 
Asymptotic notations
Nikhil Sharma
 
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
C++ Data Structure PPT.ppt
Mukesh Thakur
 
Binary search tree operations
Kamran Zafar
 
image processing intensity transformation
alobaidimki
 
Binary search tree in data structures
chauhankapil
 
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Binary tree
Rajendran
 
Tree and graph
Muhaiminul Islam
 
Cursors in MySQL
Tharindu Weerasinghe
 
M.c.qs -1(number systems)
Nadeem Uddin
 
Red black tree
Dr Sandeep Kumar Poonia
 
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
Data structures - unit 1
SaranyaP45
 

Viewers also liked (20)

PPT
Uniformed tree searching
Ayaelshiwi
 
PDF
Algorithm chapter 5
chidabdu
 
PPT
Depth firstsearchalgorithm
hansa khan
 
PPT
Bfs
akila m
 
PPT
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
sumitbardhan
 
PPTX
THREADED BINARY TREE AND BINARY SEARCH TREE
Siddhi Shrivas
 
PPTX
Анализ тональности с помощью ДСМ метода
Dima Kostyaev
 
PPTX
Ідентифікація багатофакторних залежностей на основі нечіткої бази знань з рі...
Роман Тилець
 
PPTX
Экспертные системы
Отшельник
 
PPT
Нечеткие знания в экспертных системах
Спецсеминар "Искусственный Интеллект" кафедры АЯ ВМК МГУ
 
PDF
The Science of UX Design
Zack Naylor
 
PPTX
Lecture5
Álvaro Cárdenas
 
PPTX
Expert system (unit 1 & 2)
Lakshya Gupta
 
PDF
Logical Inference in RTE
Kilian Evang
 
PPTX
Inference rulesproofmethods
Rajendran
 
PDF
CPSC 125 Ch 2 Sec 1
David Wood
 
PDF
Mayo aug1, jsm slides (3)
jemille6
 
PDF
Logical Abduction and an Application on Business Rules Management
Tobias Trapp
 
PPT
Backtracking
cristian torres
 
PPTX
Proofs by contraposition
Abdur Rehman
 
Uniformed tree searching
Ayaelshiwi
 
Algorithm chapter 5
chidabdu
 
Depth firstsearchalgorithm
hansa khan
 
Bfs
akila m
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
sumitbardhan
 
THREADED BINARY TREE AND BINARY SEARCH TREE
Siddhi Shrivas
 
Анализ тональности с помощью ДСМ метода
Dima Kostyaev
 
Ідентифікація багатофакторних залежностей на основі нечіткої бази знань з рі...
Роман Тилець
 
Экспертные системы
Отшельник
 
Нечеткие знания в экспертных системах
Спецсеминар "Искусственный Интеллект" кафедры АЯ ВМК МГУ
 
The Science of UX Design
Zack Naylor
 
Expert system (unit 1 & 2)
Lakshya Gupta
 
Logical Inference in RTE
Kilian Evang
 
Inference rulesproofmethods
Rajendran
 
CPSC 125 Ch 2 Sec 1
David Wood
 
Mayo aug1, jsm slides (3)
jemille6
 
Logical Abduction and an Application on Business Rules Management
Tobias Trapp
 
Backtracking
cristian torres
 
Proofs by contraposition
Abdur Rehman
 
Ad

Similar to Bca ii dfs u-3 tree and graph (20)

PPTX
Bsc cs ii dfs u-3 tree and graph
Rai University
 
PPTX
Mca iii dfs u-4 tree and graph
Rai University
 
PPTX
D9-Tree and Graph-Data-Structures information.pptx
naitikchoubey70
 
PPTX
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
PDF
unit-2-dsa-tree introduction of tree and terninology
sayalijscoe2
 
PPTX
Saikat techhnology of techtechhnology of techGhorai.pptx
RehanHussanCSE
 
PPTX
Tree.pptx
worldchannel
 
PPTX
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
DRCARIBOU
 
PPT
Tree 11.ppt
DEEPAK948083
 
PPTX
tree-160731205832.pptx
MouDhara1
 
PPTX
B tree ,B plus and graph
RaaviKapoor
 
PPTX
Unit 3 trees
LavanyaJ28
 
PPTX
Tree
knightofheart
 
PDF
unit-2-dsa-tree-2024-1 (1) (1).pdf data structure
SanketDawbhat
 
PPTX
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
tpvvsreenivasarao
 
PPT
Data Structures 5
Dr.Umadevi V
 
PDF
Module - 5_Trees.pdf
AnuradhaJadiya1
 
PPTX
unit-2-data structure and algorithms-tree-2024-1.pptx
pritimalkhede
 
PPT
Data Structures 4
Dr.Umadevi V
 
PPTX
trees in data structure
shameen khan
 
Bsc cs ii dfs u-3 tree and graph
Rai University
 
Mca iii dfs u-4 tree and graph
Rai University
 
D9-Tree and Graph-Data-Structures information.pptx
naitikchoubey70
 
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
unit-2-dsa-tree introduction of tree and terninology
sayalijscoe2
 
Saikat techhnology of techtechhnology of techGhorai.pptx
RehanHussanCSE
 
Tree.pptx
worldchannel
 
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
DRCARIBOU
 
Tree 11.ppt
DEEPAK948083
 
tree-160731205832.pptx
MouDhara1
 
B tree ,B plus and graph
RaaviKapoor
 
Unit 3 trees
LavanyaJ28
 
unit-2-dsa-tree-2024-1 (1) (1).pdf data structure
SanketDawbhat
 
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
tpvvsreenivasarao
 
Data Structures 5
Dr.Umadevi V
 
Module - 5_Trees.pdf
AnuradhaJadiya1
 
unit-2-data structure and algorithms-tree-2024-1.pptx
pritimalkhede
 
Data Structures 4
Dr.Umadevi V
 
trees in data structure
shameen khan
 
Ad

More from Rai University (20)

PDF
Brochure Rai University
Rai University
 
PPT
Mm unit 4point2
Rai University
 
PPT
Mm unit 4point1
Rai University
 
PPT
Mm unit 4point3
Rai University
 
PPT
Mm unit 3point2
Rai University
 
PPTX
Mm unit 3point1
Rai University
 
PPTX
Mm unit 2point2
Rai University
 
PPT
Mm unit 2 point 1
Rai University
 
PPT
Mm unit 1point3
Rai University
 
PPT
Mm unit 1point2
Rai University
 
PPTX
Mm unit 1point1
Rai University
 
DOCX
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Rai University
 
PPTX
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Rai University
 
PPTX
Bsc agri 2 pae u-4.3 public expenditure
Rai University
 
PPTX
Bsc agri 2 pae u-4.2 public finance
Rai University
 
PPS
Bsc agri 2 pae u-4.1 introduction
Rai University
 
PPT
Bsc agri 2 pae u-3.3 inflation
Rai University
 
PPTX
Bsc agri 2 pae u-3.2 introduction to macro economics
Rai University
 
PPTX
Bsc agri 2 pae u-3.1 marketstructure
Rai University
 
PPTX
Bsc agri 2 pae u-3 perfect-competition
Rai University
 
Brochure Rai University
Rai University
 
Mm unit 4point2
Rai University
 
Mm unit 4point1
Rai University
 
Mm unit 4point3
Rai University
 
Mm unit 3point2
Rai University
 
Mm unit 3point1
Rai University
 
Mm unit 2point2
Rai University
 
Mm unit 2 point 1
Rai University
 
Mm unit 1point3
Rai University
 
Mm unit 1point2
Rai University
 
Mm unit 1point1
Rai University
 
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Rai University
 
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Rai University
 
Bsc agri 2 pae u-4.3 public expenditure
Rai University
 
Bsc agri 2 pae u-4.2 public finance
Rai University
 
Bsc agri 2 pae u-4.1 introduction
Rai University
 
Bsc agri 2 pae u-3.3 inflation
Rai University
 
Bsc agri 2 pae u-3.2 introduction to macro economics
Rai University
 
Bsc agri 2 pae u-3.1 marketstructure
Rai University
 
Bsc agri 2 pae u-3 perfect-competition
Rai University
 

Recently uploaded (20)

PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT on the Development of Education in the Victorian England
Beena E S
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 

Bca ii dfs u-3 tree and graph

  • 1. Course: BCA-II Subject: Data Structure Unit-3 Tree and Graph
  • 2. NONLINEAR DATA STRUCTURE  2 primary types: • Trees • Graphs • All trees are graphs, but not all graphs are trees • Recursion is useful and is the easiest way to process them. • It helps keep track of what's been processed and what remains
  • 3. Graphs •Graphs can have multiple references in and multiple references out (whereas tree node only has one reference in) •Graphs can be directed or undirected and cyclic or acyclic
  • 4. Trees • Single parent • 0 or more children • A node with no children is called a "leaf" • The topmost node is called the "root" • N-ary trees • Binary trees
  • 5. N-ary Trees  The best example of an n-ary tree is your computer’s directory system.  It has a single starting point and then 0 or more branches.
  • 6. Binary Trees and Binary Search Trees • Binary search trees allow for fast insertion and removal of elements • They are specially designed for fast searching • A binary tree consists of two nodes, each of which has two child nodes • All nodes in a binary search tree fulfill the property that: • Descendants to the left have smaller data values than the node data value • Descendants to the right have larger data values than the node data value
  • 7. BST Tree Nodes • All nodes in a binary search tree fulfill the property that: • Descendants to the left have smaller data values than the node data value • Descendants to the right have larger data values than the node data value
  • 8. BST (Balanced Binary Trees) • Balanced tree: each node has approximately as many descendants on the left as on the right • If a binary search tree is balanced, then adding an element takes O(log(n)) time • If the tree is unbalanced, insertion can be slow • Perhaps as slow as insertion into a linked list
  • 9. Traversing a Tree  Which were used for the binary tree can now be used for the general.  When the general tree has been represented as a binary tree, the algorithms l tree.  In-order traversals make no sense when a general tree is converted to a binary tree.  In the general tree each node can have more than two children so trying to insert the parent node in between the children is rather difficult, especially if there is an odd number of children.  Pre - order  This is a process where the root is accessed and processed and then each of the subtrees is preorder processed. It is also called a depth-first traversal.
  • 10. Traversing a Tree  Pre-order Traversal  In this way the resulting printout has all nodes at any given level starting in the same tab column.  It is relatively easy to draw lines to produce the original general tree except that the tree is on its side with it's root at the left rather than with the root at the top.
  • 11. Tree Traversal • Tree traversal schemes include • Preorder traversal (root, left, right) • Inorder traversal (left, root, right) • Postorder traversal ( left, right, root) • Preorder generates prefix expression,(polish notation) from an expression trees • Inorder generates a sorted ordering • Postorder generates a post fix expression, also useful for node deletion
  • 12. Height of a BST  Insert 7  Insert 4  Insert 1  Insert 9  Insert 5  It’s a complete tree! 7 4 9 1 5 height = log(5)+1 = 3
  • 13. BSTs with heights O(log n)  It would be ideal if a BST was always close to a full binary tree  It’s enough to guarantee that the height of tree is O(log n)  To guarantee that we have to make the structure of the tree and insertion and deletion algorithms more complex  e.g. AVL trees (balanced), 2-3 trees, 2-3-4 trees (full but not binary), red–black trees (if red vertices are ignored then it’s like a full tree)
  • 14. What is a graph?  A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes to each other  The set of edges describes relationships among the vertices
  • 15. Formal definition of graphs  A graph G is defined as follows: G=(V,E) V(G): a finite, nonempty set of vertices E(G): a set of edges (pairs of vertices)
  • 16. Directed vs. undirected graphs (cont.)  When the edges in a graph have a direction, the graph is called directed (or digraph)  When the edges in a graph have no direction, the graph is called undirected.  Warning: if the graph is directed, the order of the vertices in each edge is important !!
  • 17. Breadth-first searching[1]  A breadth-first search (BFS) explores nodes nearest the root before exploring nodes further away  For example, after searching A, then B, then C, the search proceeds with D, E, F, G  Node are explored in the order A B C D E F G H I J K L M N O P Q  J will be found before N L M N O P G Q H JI K FED B C A
  • 18. Depth-first searching[2]  A depth-first search (DFS) explores a path all the way to a leaf before backtracking and exploring another path  For example, after searching A, then B, then D, the search backtracks and tries another path from B  Node are explored in the order A B D E H L M N I O P C F G J K Q  N will be found before JL M N O P G Q H JI K FED B C A
  • 19. A spanning tree of a graph is just a subgraph that contains all the vertices and is a tree. A graph may have many spanning trees. o r o r o r Some Spanning Trees from Graph AGraph A Spanning Trees
  • 20. Minimum Spanning Trees The Minimum Spanning Tree for a given graph is the Spanning Tree of minimum cost for that graph. 5 7 2 1 3 4 2 1 3 Complete Graph Minimum Spanning Tree
  • 21. References  An introduction to Datastructure with application by jean Trembley and sorrenson  Data structures by schaums and series –seymour lipschutz  http://en.wikipedia.org/wiki/Book:Data_structures  http://www.amazon.com/Data-Structures-Algorithms  http://www.amazon.in/Data-Structures-Algorithms-Made-Easy/dp/0615459811/  http://www.amazon.in/Data-Structures-SIE-Seymour-Lipschutz/dp  List of Images 1. http://www.algolist.net/Algorithms/Graph/Undirected/breadth-first_search 2. http://www.expertsmind.com/questions/depth-first-search-30153061.aspx