Answered step by step
Verified Expert Solution
Link Copied!

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

#include using 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

Evaluate the terms, BTI, ELM and strategic eclipse.

Answered: 1 week ago

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago