Question

1.2 Task 2:

Allocate an array with size and fill it with random numbers using the to seed the random

number generator. To get the most noticeable effect use the Integer type rather than the primitive int

type. For times do the following:

Calculate the time to access each element in the first 10% of the array and a single random element in

the last 10% of the array.

Next, calculate the sum of each of the elements accessed and report the following averages:

1. Time to access a single element in the first 10% of the array.

2. Time to access a single random element in the last 10% of the array.

3. Average sum of the elements.

It may be helpful to store the total access time with two variables, one for the first 10% access time,

than with one for the single element last 10% access time. This will make it easier to find the average

time for all experiments.

Note: Do not use Random.nextInt(lowerBound, upperBound) as that is exclusive to later versions of

Java and will not compile on our version of Java. You will have to figure out another way to get an index

within the last 10% of the array.

Question image 1