Breadth-first graph search problem

I thought I was doing breadth-first graph search correctly, but my instructor’s grading script is telling me that my answer is incorrect.

From the instructions:

Consider a breadth-first graph search on the graph below, where S is the start and G is the goal state. Assume that ties are broken alphabetically (so a partial plan S->X->A would be expanded before S->X->B and S->A->Z would be expanded before S->B->A). You may find it helpful to execute the search on scratch paper.

Please enter the final path returned by breadth-first graph search in the box below. Your answer should be a string with S as your first character and G as your last character. Don’t include arrows or spaces in your submission. For example, if you believe the path is S->X->G, please enter SXG in the box.

I got and input the answer SACBG, which the grading script marked as incorrect. (“Your input was evaluated as SACBG, which is not correct.”)

Here are my steps for the breadth-first graph search on the above graph using the algorithm at http://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode:

  1. Enqueue the root node S. Queue = [S], Path = []
  2. Dequeue S and examine it. Queue = [], Path = [S]
  3. Enqueue S‘s children, A and C. Queue = [A, C], Path = [S]
  4. Dequeue A and examine it. Queue = [C], Path = [S, A]
  5. A has no children. Dequeue C and examine it. Queue = [], Path = [S, A, C]
  6. Enqueue C‘s children B and G. Queue = [B, G], Path = [S, A, C]
  7. Dequeue B and examine it. Queue = [G], Path = [S, A, C, B]
  8. B‘s only child G is already in the queue. Queue = [G], Path = [S, A, C, B]
  9. Dequeue the goal node G and examine it. Quit the search and return. Queue = [], Path = [S, A, C, B, G]

A node is placed in the path when it is dequeued and examined.

Ties are broken alphabetically as required in the instructions.

What am I doing wrong?

The problem appears to be that your answer is the order in which the nodes are evaluated by the breadth first search but what the questions asks for is the final path from S to G that the search would find.

I think the answer the question is looking for is SCG.

Easiest way to confirm would be to talk to your instructor.

(A depth first search using the same alphabetical precedence rules would return SCBG as the path.)

2

Since nobody provided the details yet, here is your answer with correction:

  1. Enqueue the root node S. Queue = [S], Path = []
  2. Dequeue S and examine it. Queue = [], Path = [S]
  3. Enqueue S’s children, A and C. Queue = [A, C], Path = [S]
  4. Dequeue A and examine it. Queue = [C], Path = [S, A]
    -> All correct so far
  5. A has no children. Dequeue C and examine it. Queue = [], Path = [S, C]
    -> This is where the mistake was: A is removed from the path, as well, since it has no children; the search switches from path S-A (a dead end) to path S-C now.
  6. Enqueue C’s children B and G. Queue = [B, G], Path = [S, C]
    -> Correct, except the current path is S-C (not S-A-C).
  7. Dequeue B and examine it. Queue = [G], Path = [S, C, B]
  8. B’s only child G is already in the queue. Queue = [G], Path = [S, C, B]
    -> Correct, with the same correction as above (A is not in the path anymore).
  9. Dequeue the goal node G and examine it. Quit the search and return. Queue = [], Path = [S, C, G]
    -> Dequeue G and examine it, find it’s a goal, stop. Same mistake as above: B is removed from the path, and the search switches from path S-C-B to S-C-G (which happens to be the solution path).

Note that, if all edges have the same weight (of 1, as is your case), then breadth-first search finds the shortest path (minimum number of steps).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Breadth-first graph search problem

I thought I was doing breadth-first graph search correctly, but my instructor’s grading script is telling me that my answer is incorrect.

From the instructions:

Consider a breadth-first graph search on the graph below, where S is the start and G is the goal state. Assume that ties are broken alphabetically (so a partial plan S->X->A would be expanded before S->X->B and S->A->Z would be expanded before S->B->A). You may find it helpful to execute the search on scratch paper.

Please enter the final path returned by breadth-first graph search in the box below. Your answer should be a string with S as your first character and G as your last character. Don’t include arrows or spaces in your submission. For example, if you believe the path is S->X->G, please enter SXG in the box.

I got and input the answer SACBG, which the grading script marked as incorrect. (“Your input was evaluated as SACBG, which is not correct.”)

Here are my steps for the breadth-first graph search on the above graph using the algorithm at http://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode:

  1. Enqueue the root node S. Queue = [S], Path = []
  2. Dequeue S and examine it. Queue = [], Path = [S]
  3. Enqueue S‘s children, A and C. Queue = [A, C], Path = [S]
  4. Dequeue A and examine it. Queue = [C], Path = [S, A]
  5. A has no children. Dequeue C and examine it. Queue = [], Path = [S, A, C]
  6. Enqueue C‘s children B and G. Queue = [B, G], Path = [S, A, C]
  7. Dequeue B and examine it. Queue = [G], Path = [S, A, C, B]
  8. B‘s only child G is already in the queue. Queue = [G], Path = [S, A, C, B]
  9. Dequeue the goal node G and examine it. Quit the search and return. Queue = [], Path = [S, A, C, B, G]

A node is placed in the path when it is dequeued and examined.

Ties are broken alphabetically as required in the instructions.

What am I doing wrong?

The problem appears to be that your answer is the order in which the nodes are evaluated by the breadth first search but what the questions asks for is the final path from S to G that the search would find.

I think the answer the question is looking for is SCG.

Easiest way to confirm would be to talk to your instructor.

(A depth first search using the same alphabetical precedence rules would return SCBG as the path.)

2

Since nobody provided the details yet, here is your answer with correction:

  1. Enqueue the root node S. Queue = [S], Path = []
  2. Dequeue S and examine it. Queue = [], Path = [S]
  3. Enqueue S’s children, A and C. Queue = [A, C], Path = [S]
  4. Dequeue A and examine it. Queue = [C], Path = [S, A]
    -> All correct so far
  5. A has no children. Dequeue C and examine it. Queue = [], Path = [S, C]
    -> This is where the mistake was: A is removed from the path, as well, since it has no children; the search switches from path S-A (a dead end) to path S-C now.
  6. Enqueue C’s children B and G. Queue = [B, G], Path = [S, C]
    -> Correct, except the current path is S-C (not S-A-C).
  7. Dequeue B and examine it. Queue = [G], Path = [S, C, B]
  8. B’s only child G is already in the queue. Queue = [G], Path = [S, C, B]
    -> Correct, with the same correction as above (A is not in the path anymore).
  9. Dequeue the goal node G and examine it. Quit the search and return. Queue = [], Path = [S, C, G]
    -> Dequeue G and examine it, find it’s a goal, stop. Same mistake as above: B is removed from the path, and the search switches from path S-C-B to S-C-G (which happens to be the solution path).

Note that, if all edges have the same weight (of 1, as is your case), then breadth-first search finds the shortest path (minimum number of steps).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật