Thread: help with pseudocode?

  1. #1
    Unregistered
    Guest

    Unhappy help with pseudocode?

    i dont know much about c++, but i wanted to help a friend get this into c++ code.. any help would be great =)



    Initialize Finished and Queue;

    int count = limit read in from user;
    Node * initialPosition = node containing initial board position;
    Node * finalPosition = node containing final board position;
    Set pred pointer of initialPosition to NULL;
    Add initialPosition to queue;

    while( Queue not empty )
    {
    Remove a node N from Queue;

    if ( N is in Finished )
    ; // do nothing
    else if ( N is the same as finalPosition )
    {
    Report success and print pred list from N to initialPosition in reverse (i.e., N last);
    Exit;
    }
    else
    {
    count --
    if(count == 0) // Count unique board positions examined
    {
    Tell user that can't find board within limit;
    Exit;
    }

    Insert N into Finished;
    Generate a list L of all children of N;
    forall M in L
    if( M is not in Finished )
    {
    Set the pred pointer of M to point to N;
    Add M to the Queue;
    }

    }
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >but i wanted to help a friend get this into c++ code.. any help would be great =)
    So what is your problem so far? Have you run through the pseudocode on paper to see if the algorithm works? If so then transferring it into C++ is relatively trivial if you have a good reference handy.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pseudocode for multiple source files
    By Calef13 in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2007, 09:07 AM
  2. URGENT Pseudocode help!!!
    By mcgeady in forum C Programming
    Replies: 10
    Last Post: 11-17-2004, 09:03 PM
  3. Poll: Is pseudocode really needed ?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 29
    Last Post: 02-28-2002, 06:33 PM
  4. Replies: 1
    Last Post: 02-24-2002, 06:22 AM
  5. pseudocode, algorithm and flowwchart
    By ucme_me in forum C Programming
    Replies: 1
    Last Post: 10-31-2001, 12:11 AM