Breadth First Search in C++
CoderSource.net
Breadth First Search in C++ - Article by breakaleg
Level: AdvancedType: Article
Rating: Page: 1 of 3

Date: 7/27/2005 12:00:00 AM

Environment: C++

  Consider the following problem.

You are given the maze figure below and asked to find a way to the exit with a minimum number of decisions to make (a decision is required whenever there is at least one available direction to go). At the right of the maze figure we have pointed out these critical positions and given them numbers. Also the circles coloured in cyan are the start (1) and the finish (10).

On the basis of this diagram we will draw a graph with the following rules :

  • the vertices are the critical positions

  • there is an edge from X to Y if we can go from X to Y by making exactly one decision

It is easy to see now that the minimum length path is 1, 3, 14, 15, 10 with 4 decisions to make (the number of edges connecting the vertices). This is because we have an overview of the maze, we know every detail about it in advance. But what if we do not ? We would never be aware of the consequences of our current decision until we make it. What would be our strategy then ?

1 2 3

You Can Rate this Article, if you are Logged In      
 

More Links from CoderSource.net:

 
Refer to a Friend:

Your Details:

Name:     e-mail:

Friend Details:

Name:    e-mail:    


MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Add to Google
Add to My Yahoo!
Welcome to Codersource.Net Login | Register | Faq  

SEARCH
Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us