Tracing an Algorithm

The purpose of tracing an algorithm is to ensure that it works. This is a paper test. Tracing involves “executing” the sequence of instructions with a sample set of values, computing by hand the value of each variable after each instruction is executed, and checking for the correct result.

See the following example:

Leave a Reply

Your email address will not be published. Required fields are marked *