C++

Wasif G.

asked • 12/03/20

c++ programming

(i) Consider the following code:


int myFunc(int A[], int n) 

    int i, j, max = 0; 

    int msis[n]; 

  

    for ( i = 0; i < n; i++ ) 

        msis[i] = A[i]; 

  

    for ( i = 1; i < n; i++ ) 

        for ( j = 0; j < i; j++ ) 

            if (A[i] > A[j] && 

                msis[i] < msis[j] + A[i]) 

                msis[i] = msis[j] + A[i]; 

  

    for ( i = 0; i < n; i++ ) 

        if ( max < msis[i] ) 

            max = msis[i]; 

  

    return max; 

}

a)     What is the time complexity of the algorithm?


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.