Discussion
In breadth first search of a graph, which data structure is used to hold nodes ?
Answer: B
Breadth-first search uses a queue.
BFS visits vertices level by level. Discovered vertices are added to the rear of a first-in, first-out queue, and the next vertex to explore is taken from the front, so all vertices at distance k are processed before any at distance k + 1.
A stack, last-in first-out, gives depth-first search instead. An array can store the graph or the visited flags but does not by itself impose the FIFO order, and 'graph' is the structure being searched, not the holder of pending nodes.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development