The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
63 views

asked in Programming by Junior (939 points) | 63 views
0
Is it $3$?
0
Yeah 3
0
i also got 3 , but the answer given is 4
0
Post their provided solution.
+2
here not given which node have to choose. I think we have to go to the worst case.

When we select the node E, or B, C , G, or F node.

Then size will be 4.
+1
Nice
0

what will be the size of the $stack$ in case of $DFS$ ???

0
if considering the worst case, then the minimum size should be 5.

if starting from node C, first enqueue B,E,G,D. then dequeue B and enqueue all it's neighbour. so queue will now look like.. E,C,G,D,A,F. this is the maximum elements possible at one time in the queue. isn't it?

please correct me if i'm wrong.

1 Answer

0 votes

Well in worst case answer will be 4

If you start bfs from E, ans will be 4. So a min. Queue size of 4 is reqd. With a queue of size 3, you can't do bfs from E.

answered by Active (2.4k points)

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

47,080 questions
51,333 answers
177,707 comments
66,675 users