subject

Download "ADDING 1 to n" program in "COURSE MATERIALS" . Find the runtime function as a function n. Remember f count each operative statement (of course comments don't count). Also write the order ("Big O"). Show work.
#include c1
using namespace std; c2
int add(int n); c3
int main() c4
{
int n; c5
cout << "Enter a nonnegative integer: "; c6
cin >> n; c7
cout << "Sum = " << add(n); c8
system("pause"); c9
return 0; c10
}
int add(int n) c11 n
{
if(n == 0) // BASE CASE c12 n
return 0; c13
else c14 n-1
return n + add(n-1); // RECURSIVE CASE c15 n-1
}

a = sum of(c1 through c10) + c12 + c13
b = c14 + c15
d = c11
a + b(n-1) + dn = (b+d)n + a - b
linear f(n) O(n)
n + 2(n-1) + 12

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, jonquil201
Where would you click to edit the chart data?
Answers: 1
image
Computers and Technology, 22.06.2019 22:40, nsuleban9524
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
image
Computers and Technology, 24.06.2019 07:00, sudotoxic
Into what form does the barcode reader convert individual bar patterns?
Answers: 1
image
Computers and Technology, 24.06.2019 09:00, king514
Technician a says that a new replacement part is always good. technician b says that sometimes recent repair work will be the cause of a complaint. who is correct? a. both technicians a and b b. technician a c. technician b d. neither technician a nor b
Answers: 3
You know the right answer?
Download "ADDING 1 to n" program in "COURSE MATERIALS" . Find the runtime function as a function n....

Questions in other subjects:

Konu
Chemistry, 09.01.2021 15:10
Konu
Chemistry, 09.01.2021 15:10
Konu
Mathematics, 09.01.2021 15:10
Konu
Mathematics, 09.01.2021 15:10