image University of Washington Computer Science & Engineering
  CSE 421Su '04:  FAQ
  CSE Home   About Us    Search    Contact Info 

  1. Q.  How detailed should my algorithm be?

    E.g., if I want the vertex that has the lowest number, may I write?:

            Vertex := Min (VertexA, VertexB);
    
    Or should I be more detailed?:
            temp := vertexA; 
            if(vertexB < vertexA) temp:=vertexA;
    

    A:   I don't want code, I want a clear, understandable description of the method. A program is a communication between you and a machine; an algorithm is a communication between you and another human about a program.

    E.g., "Min (VertexA, VertexB)" is fine, but I'd be just as happy with English: "between vertices A and B, choose the one with the smaller vertex number", or "keep an array with an entry for each vertex holding the count of the number of times that vertex is reached during process X and find the vertex with the min count." If you need a balanced binary search tree, say "using an AVL tree from chapter 4 or my data structures class, we can ..."; definitely don't give me AVL code.

    The basic issue is that you should break the problem down into steps that are clear enough that everyone else in the class should be able to:

    And it should be clearly organized so that the "big picture" is evident and so that you can argue that your algorithm is correct. In general, I want at least a sketch of correctness with all your algorithms, unless I say otherwise. For a problem where you give the "inductive" view, the description of the algorithm and its correctness proof should pretty much fit hand-in-glove, but do pay attention to both aspects.


    Portions of the CSE 421 Web may be reprinted or adapted for academic nonprofit purposes, providing the source is accurately quoted and duly credited. The CSE 421 Web: © 1993-2004, Department of Computer Science and Engineering, University of Washington.


    CSE logo Computer Science & Engineering
    University of Washington
    Box 352350
    Seattle, WA  98195-2350
    (206) 543-1695 voice, (206) 543-2969 FAX
    [comments to cse421-webmaster@cs.washington.edu]