Question
It is start with node O Explain , why this nodes are visited in this graph for getting this traversal order : O H R
It is start with node O
Explain , why this nodes are visited in this graph for getting this traversal order : O H R S T C N V A G I B D E F J K L M P Q U
for BFS
graph = {
'A': ['B', 'D'],
'B': ['E', 'F'],
'C': ['A', 'G', 'I'],
'D': ['J'],
'E': ['K', 'L'],
'F': ['M'],
'G': [],
'H': ['T','C'],
'I': [],
'J': ['P', 'Q'],
'K': [],
'L': [],
'M': [],
'N': [],
'O': ['H', 'R', 'S'],
'P': [],
'Q': ['U'],
'R': ['N'],
'S': ['V'],
'T': [],
'U': [],
'V': []
}
next is for DFS : O H C A B E K L F M D J P Q U G I N R S V T
graph = {
'A': ['B', 'D'],
'B': ['E', 'F'],
'C': ['A', 'G', 'I'],
'D': ['J'],
'E': ['K', 'L'],
'F': ['M'],
'G': [],
'H': ['C'],
'I': ['N'],
'J': ['P', 'Q'],
'K': [],
'L': [],
'M': [],
'N': [],
'O': ['H', 'R', 'S'],
'P': [],
'Q': ['U'],
'R': [],
'S': ['V','T'],
'T': [],
'U': [],
'V': []
}
based on this picture
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started