algorithm - Breadth First Search queue -


i looking @ assignment:

consider 2 vertices , b simultaneously on fifo queue @ same point during execution of breadth first search s in undirected graph.

which of following true?

  1. the number of edges on shortest path between s , atmost 1 more number of edges on shortest path between s , b.
  2. the number of edges on shortest path between s , atleast 1 less number of edges on shortest path between s , b.
  3. there path between , b.

possible answers:

a) 1 only

b) 1 , 2 only

c) 2 only

d) 1, 2 , 3

i know how solve , m having doubt in meaning of statement

...that simultaneously on fifo queue @ same point during execution of breadth first search...

what exact meaning of this?

as @beaker commented, there typo in assignment. word same should read some:

consider 2 vertices , b simultaneously on fifo queue @ some point during execution of breadth first search s in undirected graph.

by definition of breadth-first, nodes find in queue after nth iteration of search, n steps away starting node s. when going next iteration, distance increased 1, , every node in queue taken out of queue 1 one, in order shift in neighbors, 1 step further away s. while process half-way, there nodes @ distance n , nodes @ distance n+1 in queue, until of distance n have been processed , removed queue.

this means @ given moment, 2 nodes in queue, cannot differ more 1 step in distance s.

i must phrase "is @ least 1 less than" in premise 2 bit ambiguous: "at least" interpreted mathematically, i.e. "not smaller than": dist(a,s)>=dist(b,s)-1.

finally, since undirected graph, , have found path s a , path s b, there path a b (via s).

this solves question.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -