Answer

We will need an extra array, newtemps, of the same size as oldtemps. We will use oldtemps to contain the current temperatures, and newtemps to contain the temperatures after one clock tick.

The value of an element newtemps[i] in the interior of newtemps will depend upon oldtemps[i-1], oldtemps[i], and oldtemps[i+1] according to our formula for heat propagation.

Once we have completely calculated every entry of newtemps, we need to copy them into oldtemps in preparation for the next round of calculations.

Return to lesson.



Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah