lundi 25 janvier 2016

How to dry run with Trace Tables

This is a basic question on the use of Trace Tables to assist in a dry run of a simple algorithm.

What I find most tricky is when to take a new line in the trace table? For example, take the following question:

enter image description here

Here is the array of integers which it applies to: enter image description here

The following trace table is presented as one completes a dry run. Here is the solution:

enter image description here

I understand that initialising the variables Number, Lower & Upper appear on the first line, but when I go into the While Loop, I am tempted to put the value 5 on the first line also, for the variable Current. In essence, this is what I am tempted to do:

enter image description here

Why does this solution require that the value for Current, which is 5, appear on the second line? I suppose the question could be rephrased to 'When do I take a new line in a trace table?'

This is elementary level, so please address any responses at a beginner/pupil level.

Thanks.

Aucun commentaire:

Enregistrer un commentaire