breadth first search

Charles Krug cdkrug at aol.com
Wed Feb 8 18:04:58 EST 2006


On 2006-02-08, News <nickyncy at yahoo.com.hk> wrote:
> I am new in using Python
>
> Anyone know how to implement breadth first search using Python?  Can Python
> create list dynamically, I want to implement a program which will read data
> from a file and store each line into a list, is this possible?
>
> Please send mail to me at nickyncy at yahoo.com.hk or reply this mail
>
> Thanks a lot!
>

Yes.  List has methods that support a stack, in case you find it useful
in this context.

Yes.  List has methods that allow dynamic creation, such as might be
useful when implementing a stack, in case you find it useful in this
context.

And Yes.  File has methods that will populate a list from a file.
Examples are in the tutorials.

You're welcome.

You can find numerous examples of the breadth-first algorithm on the
web.  You can then take the individual steps and translate them into
Python.  You'll likely find one or two sticking points, but the
implementation is straightforward from pseudocode or from a GOOD
statement of the algorithm.




More information about the Python-list mailing list