Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NOTE: PLEASE ANSWER THE QUESTION IN CLEAR AND AS POSSIBLE AS SIMPLE STEPS. I APPRECIATE IF YOU COULD USE COMMENTS. IN COMPLETE AND WRONG ANSWERS
NOTE: PLEASE ANSWER THE QUESTION IN CLEAR AND AS POSSIBLE AS SIMPLE STEPS. I APPRECIATE IF YOU COULD USE COMMENTS. IN COMPLETE AND WRONG ANSWERS WILL GET THUMBS DOWN.
THANK YOU.
For the given program below calculate the function for the runtime and categorize it as constant, linear, log, quadratic
// PROGRAM STARTS HERE
#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