1.

Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1)(a) Can be anything(b) 0(c) At most 1(d) Insufficient InformationThis question was addressed to me in class test.This intriguing question comes from Breadth First Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

Right option is (c) At most 1

For explanation: In the queue, at a time, only those nodes will be there WHOSE difference among levels is 1. Same as LEVEL order TRAVERSAL of the TREE.



Discussion

No Comment Found

Related InterviewSolutions