Question: 1.Determine a detailed cost function for the function. This function should be written in the form wnx + yn + z where w, x, y

1.Determine a detailed cost function for the function. This function should be written in the form wnx + yn + z where w, x, y and z are real numbers and n is a variable referring to the size of the function's input. If necessary, you should adapt this format to include other terms such as log2(n).

2. Identify (one of) the barometer operations for the function.

3. Identify the O notation running time of the function.

Notes

1. The function should be modified to include an integer reference parameter the value of which should be set to the operation count

2. The input size is the number of rows of the matrix

3. Lines that include call(s) to the rcIndex function (which has a constant time complexity) still only count as a single operation as per rule 1

// PRE: m represents a square matrix of size rows * rows

// PARAM: rows represents the number of both rows and columns

// POST: Returns a pointer to an array (matrix) of the same size as m

// NOTE: values are indexed r0c0,r0c1,,r0cn-1,r1c0,

int* matrixSelfMultiply(int* m, int rows) {

// Create result array

int columns = rows;

int* result = new int[rows * columns];

int r = 0;

while (r < rows) {

int c = 0;

while (c < columns) {

//columns = rows

int next = 0;

int iNext = 0;

while (iNext < rows) {

next += m[rcIndex(r, iNext, columns)] * m[rcIndex(iNext, c, columns)];

iNext++;

}

result[rcIndex(r, c, columns)] = next; c++;

}

r++;

}

return result; }

// Returns the index of a 1d array representing a matrix

// given row (r) and column (c) values

int rcIndex(int r, int c, int columns)

{ return r * columns + c; }

c++ by the way

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!