Given the graph G from Question 2, using the Graph Breadth-First Search algorithm with a Queue, please do the following: Assume that the start node is 4 (e.g. node = 4). Demonstrate a step-by-step, manual desk-check execution of the BFS algorithm, showing the values of all variables and arrays (e.g. visited, inqueue, Q) for each step in each cycle of each loop, as demonstrated in class. [ Algorithm: Graph breadth-first search BFS (G, node) → →visited Input: G = (V, E), a graph node, the starting vertex in G Output: visited, an array of size [V] such that visited[i] is TRUE if we have visited node i, FALSE otherwise 1 Q-CreateQueue () 2 - visited CreateArray (VI) inqueue CreateArray (VI) 3 t 4 for i0 to IV do

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
1
6
0
2
4
7
3
5
Graph G
Transcribed Image Text:1 6 0 2 4 7 3 5 Graph G
Given the graph G from Question 2, using the Graph Breadth-First Search algorithm with a Queue,
please do the following:
Assume that the start node is 4 (e.g. node = 4),
Demonstrate a step-by-step, manual desk-check execution of the BFS algorithm, showing the values of
all variables and arrays (e.g. visited, inqueue, Q) for each step in each cycle of each loop, as
demonstrated in class. [
Algorithm: Graph breadth-first search
BFS (G, node) →visited
3
4
5
6
Input: G = (V, E), a graph
node, the starting vertex in G
1
2 visited CreateArray (VI)
10
11
Output: visited, an array of size [V] such that visited[i] is TRUE if we
have visited node i, FALSE otherwise
Q-CreateQueue ()
-
inqueue - CreateArray (VI)
for i0 to VI do
t
visited[i] FALSE
inqueue[i] FALSE
7 Enqueue (Q, node)
8
t
inqueue[node] <-TRUE
while not IsQueueEmpty (Q) do
c← Dequeue (Q)
inqueue[c] FALSE
visited[c] TRUE
t
foreach v in AdjacencyList (G, c) do
if not visited[v] and not inqueue[v] then
12
13
14
15
16
17 return visited
t
Enqueue (Q, v)
inqueue[v] - TRUE
Transcribed Image Text:Given the graph G from Question 2, using the Graph Breadth-First Search algorithm with a Queue, please do the following: Assume that the start node is 4 (e.g. node = 4), Demonstrate a step-by-step, manual desk-check execution of the BFS algorithm, showing the values of all variables and arrays (e.g. visited, inqueue, Q) for each step in each cycle of each loop, as demonstrated in class. [ Algorithm: Graph breadth-first search BFS (G, node) →visited 3 4 5 6 Input: G = (V, E), a graph node, the starting vertex in G 1 2 visited CreateArray (VI) 10 11 Output: visited, an array of size [V] such that visited[i] is TRUE if we have visited node i, FALSE otherwise Q-CreateQueue () - inqueue - CreateArray (VI) for i0 to VI do t visited[i] FALSE inqueue[i] FALSE 7 Enqueue (Q, node) 8 t inqueue[node] <-TRUE while not IsQueueEmpty (Q) do c← Dequeue (Q) inqueue[c] FALSE visited[c] TRUE t foreach v in AdjacencyList (G, c) do if not visited[v] and not inqueue[v] then 12 13 14 15 16 17 return visited t Enqueue (Q, v) inqueue[v] - TRUE
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY