
Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.
Which data structure is used to implement Breadth-First Search?
Correct Answer: A) Queue
Step-by-step Solution: BFS visits nodes level-by-level, utilizing a FIFO Queue to track frontier nodes.
What is time complexity of BFS on an adjacency list graph with V vertices and E edges?
Correct Answer: A) O(V + E)
Step-by-step Solution: BFS visits every vertex once and checks all outgoing edges. Time complexity is O(V + E).
Always maintain a boolean 'visited' array to prevent infinite loops in cyclic graphs.