Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

View Go Tools Window Help Algo a 4.jpeg (11 documents, 11 total pages) - Edited Q Search For I - A- 1. Answer the following

image text in transcribed

View Go Tools Window Help Algo a 4.jpeg (11 documents, 11 total pages) - Edited Q Search For I - A- 1. Answer the following for the given pseudocode BFS for graphs. (10 marks) a) Why is the variable d[u) initialized to infinity in the beginning. b) What does it[u] represent. c) What is the purpose of using Q, and why don't we use stack instead. d) Run this pseudocode on the given graph and mention the values of all the variables d, T, and Q. Show all the values of the Q at each step. Se 90 do w BFS(G, S) 1 for each vertex u V[G] - {3} 2 do color[u] - WHITE 3 du] - DO 4 [U] - NIL 5 color(s) - GRAY 6 d[S]O 7 [S] - NIL 8 - {S} 9 while + 10 do u - head[Q] 11 for each v E Adj[u] 12 do if color[u] = WHITE 13 then color[v] - GRAY 14 d[v] - d[u] + 1 15 [] - 4 16 ENQUEUE(Q,v) 17 DEQUEUE(Q) 18 color[u] -- BLACK 237 DEC ME 26 W TA MacBook Air 80 DOO 000 00 DIN F? F3 FA F8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions