Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

An undirected graph has adjacency lists A:BDE B:AC C:BE D:AF E:ACF F:DE. Neighbours are always explored in alphabetical order. Which is the BFS visiting order starting at A?

  1. A. ADBECF
  2. B. ABDECF
  3. C. ABCEFD
  4. D. FCEDBA

Correct answer: B. ABDECF

BFS explores level by level with a queue, taking neighbours in alphabetical order, giving ABDECF.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic