JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat  | Threaded  | Tree
Previous Thread  |  Next Thread
I think the BFS pseudo-code should be corrected in the BFS article | Reply
Hi,

Just wanted to check if somebody can correct the following pseudo code:

I was going through the the Algorithms Tutorial, Introduction to graphs and their data structures: Section 2, and I realized that the BFS pseudo-code might have a mistake:

Where it reads:

for (int player1XDelta = -1; player1XDelta <= -1; player1XDelta++) {
for (int player1YDelta = -1; player1YDelta <= -1; player1YDelta++) {
for (int player2XDelta = -1; player2XDelta <= -1; player2XDelta++) {
for (int player2YDelta = -1; player2YDelta <= -1; player2YDelta++) {

It should read:

for (int player1XDelta = -1; player1XDelta <= 1; player1XDelta++) {
for (int player1YDelta = -1; player1YDelta <= 1; player1YDelta++) {
for (int player2XDelta = -1; player2XDelta <= 1; player2XDelta++) {
for (int player2YDelta = -1; player2YDelta <= 1; player2YDelta++) {

I noticed that the explanation is correct (we should use a for loop from -1 to 1) but the pseudo-code right after that seems to have a mistake.

Thanks.
- JA -
Subject Author Date
I think the BFS pseudo-code should be corrected in the BFS article joseangelusa Dec 1, 2010 at 2:02 PM EST
RSS