1. Considering the following array of C.A scores for Six students in three assessments. Each row
represents the scores of a single student. Answer the questions that follow.
pop_quiz = {
{4.0, 3.75, 5.00},
{2.67, 3.83, 4.97},
{4.22, 3.89, 2.77},
{4.75, 4.11, 4.63},
{2.00, 5.00, 5.00}
{3.61, 4.21, 3.66}
}
(a) How many dimensions does the array have? (b) What is the length (size) of each dimension? (c)
What is the score stored at pop quiz [3][2]?
(d) The second test was recorded incorrectly for the fifth student. Their right score is 3.31. How
can you rectify that score?
(e) Are the elements of the array homogenous or heterogeneous?
(f) What data type could you use to represent the elements of the array?
Determine the time efficiency of the following algorithm and what complexity class does it
belong to?
BEGIN
Input the number of days from the user.
II. Declare and create an int array with the number of days as its length.
III. For each index in the array:
a. Input the temperature from the user.
b. Store the temperature in the array at that index.
IV. Initialize a sum to zero.
V. For each index in the array:
a. Add the element at that index to the sum.
VI.Calculate and print the average.
VII. Initialise a counter to zero.
VIII. For each index in the array
If the element at that index is greater than the average:
Increment the counter.
Print the counter.
END
3. Given the following array: {“red”, “orange”, “yellow”, “green”, “blue”},
(a) Show and briefly explain the process of deleting the element “red”.
(b) What is the complexity of this process? No calculations are needed.
4. Is the formula for finding the location of an element in a dynamic array different from the formula for finding the
location of an element in a static array? Justify your answer.
5. When a dynamic array expands, why can’t the existing elements be left in place and extra memory simply
be allocated at the end of the existing memory allocation?
6. Suppose a dynamic integer array 𝑎 with indices beginning at 0 has 100 elements and the line of code
𝑎[100] = 𝑎[5] is executed. How many array values m