Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE

An undirected graph has adjacency lists A:BCG B:ADG C:AE D:BF E:CG F:D G:ABE. Neighbours are always explored in alphabetical order. Which is the BFS visiting order starting at A?

  1. A. ABDFGEC
  2. B. ABCGDEF
  3. C. FEDGCBA
  4. D. AGECBDF

Correct answer: B. ABCGDEF

Alphabetical neighbour order. BFS uses a queue giving ABCGDEF.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic