• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to solve This Breadth-First Search Question

Resolved: How to solve This Breadth-First Search Question

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

So my professor in college gave us a quiz, using Breadth-First Search , I answered this question as follows:-
S -> {A,B} -> {C,D,E} -> {G2}
since we found the goal then we stop , so the answer is d(otherwise) however the professor gave us the answer as b.

Can anyone explain why and how to solve this type of questions ?
enter image description here

Answer:

Ah, I just saw that you ended at G2 as opposed to G1. (At first I thought the problem was you wanting to return an answer as a list of lists.)
I would agree with you that the answer is (D). G2 is discovered as a neighbor of D, before G1 is discovered as a neighbor of E.
I don’t see how one would arrive at G1 first, unless doing something weird like sorting on insertion into the queue.

If you have better answer, please add a comment about this, thank you!

Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Modify entity using Action in C#

24/03/2023

Resolved: How to give rank on datetime column group by another column with userid in it

24/03/2023

Resolved: Passing 2 functions in onChange in react

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.