For this section, we will be using this timing framework. It is very similar to the framework you constructed earlier, but it also has the stubs for a few blocks that we will be filling in. The first block that we will fill in is already on stage:
This block should fill the input list with all of the numbers from start
to end
. If working correctly, the version used on stage should generate all of the numbers from 1
to max
, where max
is a number that we will change when running timing experiments, and should add them to the numbers
list.
First, talk to your partner and discuss an
algorithm that you can use to fill the input list with all of the
numbers from start
to end
. Once you both have decided on an algorithm, complete the body of the block. Now, run the script with max
set to 10
.
Run it a few times to get an idea of the average time the computer
takes to generate this list (to the nearest tenth of a second); you
don't need to be exact! Repeat the experiment with max
set to 20
, 40
, 100
, 200
, and 1000
. Do you see a pattern?