Hi, I basically understand the BFS and how it works, but I'm confused when it come to the queue, result, path .... etc.
For example; I have a tree graph as below:
A--B--C
|
D--E
If the starting node is A and the goal is C. As I understand, the FIFO queue will include first A, then it will be directly removed from Q, then we enqueue B and D and, We check alphabetically B first(so we dequeue B), B has an adjacent node which is the goal C.
Now I have some questions regarding this scenario?
1- Does the node c enters the queue?
2- Shall We proceed to explore the remaining nodes available in the queue (example D)? If no what will happen to the nodes in the queue after finding a target?
3- What will be the path result/output of using BFS in this scenario? Is it (A-> B-> C) OR (A-> B-> D-> C) OR (A-> B-> D-> C -> E)?
All academic references and examples that I have read doesn't explain clearly what would happen if a target is found and some other nodes still in the queue.
I appreciate any help with academic references if possible.
Best Regards
For example; I have a tree graph as below:
A--B--C
|
D--E
If the starting node is A and the goal is C. As I understand, the FIFO queue will include first A, then it will be directly removed from Q, then we enqueue B and D and, We check alphabetically B first(so we dequeue B), B has an adjacent node which is the goal C.
Now I have some questions regarding this scenario?
1- Does the node c enters the queue?
2- Shall We proceed to explore the remaining nodes available in the queue (example D)? If no what will happen to the nodes in the queue after finding a target?
3- What will be the path result/output of using BFS in this scenario? Is it (A-> B-> C) OR (A-> B-> D-> C) OR (A-> B-> D-> C -> E)?
All academic references and examples that I have read doesn't explain clearly what would happen if a target is found and some other nodes still in the queue.
I appreciate any help with academic references if possible.
Best Regards