Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve This Breadth-First Search 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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading