2. given the following graph, perform a breadth - first search (bfs) traversal starting from node a. list…

2. given the following graph, perform a breadth - first search (bfs) traversal starting from node a. list the order in which the nodes are visited. (10 points)
Answer
Explanation:
Step1: Start from node a
Visit a, enqueue its neighbors b, c, d.
Step2: Dequeue b
Visit b, enqueue its neighbors e, f.
Step3: Dequeue c
No new neighbors to enqueue.
Step4: Dequeue d
No new neighbors to enqueue.
Step5: Dequeue e
No new neighbors to enqueue.
Step6: Dequeue f
Enqueue g.
Step7: Dequeue g
No new neighbors to enqueue.
Answer:
a, b, c, d, e, f, g