Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:00, willowcollins3753
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, ksanchez2100
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, mona92
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
image
Computers and Technology, 23.06.2019 07:00, lin550
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
Do you know the correct answer?
Download "ADDING 1 to n" program in "COURSE MATERIALS" . Find the runtime function as a function n....

Questions in other subjects: