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

An undirected graph has adjacency lists A:BCDEF B:AC C:AB D:AEG E:ADG F:A G:DE. Neighbours are always explored in alphabetical order. Which is the BFS visiting order starting at A?

  1. A. AFEGDCB
  2. B. ABCDEFG
  3. C. ABCDEGF
  4. D. GFEDCBA

Correct answer: B. ABCDEFG

Alphabetical neighbour order. BFS uses a queue giving ABCDEFG.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic