Answered You can hire a professional tutor to get the answer.

QUESTION

Assignment # 01 Give detailed Time Complexity Analysis (in terms of N) of the following C++ codes in terms of Big-Oh notation and justify your...

Assignment # 01Give detailed Time Complexity Analysis (in terms of N) of the following C++ codes in terms of Big-Oh notation and justify your answer;(Where N is the input size). Label the operations.Code # 1 (5)int i=1;while(i<N){for(int j=1; j<N; j *= 5){for(int k=0;k<N;k++)cout<<”Complexity Analysis”;}i=i*3;}Code # 2 (5)int i=1000;int S=N/2;while(i>N){for(int j=1; j<=N; j++){for(int k=0;k<S;k++){k++;}}i--;}Code # 3 (5)void Func1(int N){const int MaxSize = 100;int array[MaxSize][MaxSize], k, l;for(int i=0; i<N; i++)for(int j=0; j<N; j++)array[i][j] = 0;array[0][(N-1)/2] = 1;int key = 2;i = 0;int j = (N-1)/2;while(key <= N*N){if(i <= 0)k = N-1;elsek = i-1;if(j <= 0)l = N-1;elsel = j-1; if(array[k][l])i = (i+1)%N;else{i = k;j = l;}array[i][j] = key;key++;}int str=0;for(i=0; i<N; i++){for(j=0; j<N; j++)str++;}int Sum = 0;for(i=0; i<N; i++){Sum += array[0][i];}}Code # 4 (5)void func1(int N){if(N<=1)cout<<N<<endl;else{int fn;int fnm2 = 0;int fnm1 = 1;for(int i=2; i<=N; i++){int j=10000;while(j>N){fn = fnm1 + fnm2;fnm2 = fnm1;fnm1 = fn;j--;}}}}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question