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, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Does anybody know how to hack into a google account? i had important information on it and it is gone now and i need getting it back.
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
Mathematics, 20.01.2021 22:20
question
Mathematics, 20.01.2021 22:20
question
History, 20.01.2021 22:20
question
Mathematics, 20.01.2021 22:20
Questions on the website: 13722363