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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 21:40
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
question
Computers and Technology, 24.06.2019 19:30
Can someone who is skilled at coding create me a java chess game. don't copy from online source codes. make it original ! : d
Answers: 1
question
Computers and Technology, 24.06.2019 22:30
In writing a paper for his english class, gavin quoted an author of the book. what should he include in his paper to credit the source? citation caption header entry
Answers: 1
question
Computers and Technology, 25.06.2019 03:30
All nate specialties are offered at two levels, a. journeyman and master. b. installation and service. c. apprentice and journeyman. d. heating and air conditioning.
Answers: 1
You know the right answer?
Download "ADDING 1 to n" program in "COURSE MATERIALS" . Find the runtime function as a function n....
Questions
question
Health, 18.03.2021 01:40
Questions on the website: 13722361