Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++, For the attached program write the function for the run time, and then classify it as constant, log, linear, or quadratic. #include using
In C++,
For the attached program write the function for the run time, and then classify it as constant, log, linear, or quadratic.
#includeusing namespace std; struct N { int val; N *next; }; int main() { int NUM[5]= {5,8,6,13,14}, A[5] = {-1,-1,-1,-1,-1}; for(int k=0; k<5; k++) { if(A[k]% 5 == -1) A[(NUM[k]% 5)] = NUM[k]; else if((A[k+1]% 5 == -1) && k<4 ) A[((NUM[k]+1)% 5)] = NUM[k]; else if((A[k+2]% 5 == -1) && k<3) A[(NUM[k]% 5)+2] = NUM[k]; else if((A[k+3]% 5 == -1)&& k <2) A[(NUM[k]% 5)+3] = NUM[k]; else if(A[k+4]%5 == -1) A[(NUM[k+4]%5)] = NUM[k]; else if(A[k-4]% 5 == -1) A[(NUM[k]% 5)-4] = NUM[k]; else if(A[k-3]% 5 == -1) A[(NUM[k]% 5)-3] = NUM[k]; else if(A[k-2]% 5 == -1) A[(NUM[k]% 5)-2] = NUM[k]; else if(A[k-1]% 5 == -1) A[(NUM[k]% 5)-1] = NUM[k]; } for(int k=0; k<5; k++) { cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started