Pseudocode Guidelines

  1. Begin with an English description of how the algorithm works. You may want to include examples and diagrams of the data structures that help make the operation of the algorithm more clear. About one or two paragraphs of text is usually enough. Include a general overview of the approach and goals. For recursive algorithms it is often useful to clearly describe the base and inductive cases that make the algorithm correct.

  2. Follow basic C and/or C++ syntax. Dynamically created structures should be allocated using "new" and deallocated using "delete". Avoid the use of advanced C++ features like iterators, templates, class inheritance, etc. Do not rely on pre-defined classes from the Weiss book unless that is part of the assignment.

  3. You may simplify your pseudocode by using the name of a structure type as an ordinary datatype. E.g., instead of writing
       struct node { int data ; struct node * next; };
       struct node * MyNodePtr;
    
    you may write
       struct node { int data ; node * next; }
       node * MyNodePtr;
    


  4. You can introduce definitions for the relational operators applied to non-numeric types. For example, you might write
       Define (F < G) for nodes F and G to hold iff (F.data < G.data)
    
    This should be done only to clarify, never to obscure, the presentation. If you have any questions about whether a definition or abbreviation is okay to include check with the TA.

  5. Include meaningful comments in the body of the pseudocode.

  6. Try to make the program as succinct and elegant as you can. This is not only good style but usually makes the algorithm easier for others to understand.

  7. Pseudocode should be typed (preferred) or VERY neatly handprinted. If we have difficulty reading your homework you will lose points!

CSE 326 Winter 2002 Home