U3 L3 Extra Practice -- create a trace table that

I am missing something with U3L3 Loops Extra Practices – Ext Practice(the third question) question about using a trace table. It looks as if the trace process overly complicates the trace and how information is broken out. What am I missing?

@fieldd - Dave thanks for posting to the forum. It is a great place for all of us to learn from each other. Could you post an example of what you would see as a clearer trace table? It would be good to have other examples to show our students. Thanks!

Hi David,
I have definitely done trace tables for code like this that are a different style and have fewer columns. For example, instead of keeping track of every line number, tracking the loop control variable, and the variables being changed in the body of the loop. What is in the answer key does have a lot more going on, and looks more complicated. I like the answer key’s approach with new programmers, because it allows them to visualize what order the code runs in- for example on the last pass of the loop the value of the index is 3, and line 3 runs to see that the condition is false, and then line 6 is run after the loop terminates- see the image below.
As we move into more complicated algorithms with arrays, keeping track of the state of the array can also be helpful for students.

1 Like

Hi Lindsay,

Thank you.

1 Like