Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following two functions and assume that container in foo has M data

ID: 643671 • Letter: C

Question

Consider the following two functions and assume that container in foo has M data points and the matrix in matrixPrint is 2 dimensional has M rows, M columns. Calculate the big O cost of each of these functions:

..i'm pretty sure a) is O(N^2) because of 2 for loops ... but i'm not sure about b. could you explain reasoning too? thanks!

Consider the following two functions and assume that container in foo has M data points and the matrix in matrixPrint is 2 dimensional has M rows, M columns. Calculate the big O cost of each of these functions: II This methods calculates a Hermitian product of matrix A multiplied by itself II This product is evaluated element by element as in the product below II assume the matrix is a square MxM matrix void matrixPrnt(myObj matrix)

Explanation / Answer

a) The method definition of "matrixPrint" contains two loops. So, the big-O notation is O(N2)

b) The method definition of "foo" takes an iterator range(itr) to generic processing of a container 'c'. Then, the time complexity is depends on size of container "c".

For example, size of the container c=n, then the big O cost of foo() function is O(N).