Implement the details of a recursive function

Assignment Help C/C++ Programming
Reference no: EM131206008

Problem #1

Overview: For problem 1(a) of this assignment, you will need a C++ compiler. In order to receive credit, your program must compile and run; and you must provide the actual source code file so that I can compile and I can your program (e.g. the file you modified ending in .cpp). Examples on how to import existing source code files into your compiler are provided in the file called Importing Source Code.pdf The remaining problems for the assignment must be written up within a single Microsoft Word document. You must include your name and course number within all files that you submit, including source code files as a comment at the top of each file that you create or modify.

1. Recursion. Read the assigned chapter and notes for Week I located in the Learning Activities area in Blackboard. Then provide solutions for the following:

(a) Download the g.cpp file, then using the definition below, implement the details of a recursive function called g (n) This function can be directly translated into C/C++ from the following mathematical definition:

           0                     if n ≤ 0

g (n) = n + g (n - 1)   n ≤ 1 or n ≥ 4

            n + g (n - 3)    otherwise

The function must be implemented based on the mathematical definition provided above,

Note: For this program, you only need to modify the provided file by adding the necessary code to implement the TODD areas as noted in the comments, Everything else can remain the same.

Output: The output for this program once it is implemented will be as follows:

g(-21) is 0

g(-4) is 0

g(0) is 0

g(77) is 3000 g(300) is 45147

** Press any key to continue **

(b) Perform an Internet search and provide a brief description (at least a paragraph with four to five sentences) of an example of a practical use for recursion. For example, the practical use you mention should be something other than simple function implementations such as factorial, the power of a number, Fibonacci, etc. The description must be summary in your own words and not a cut and paste from a website. Include the reference to your source or sources in APA format at the end of your description.

Problem #2

2. Complexity Analysis. Begin by reading the assigned chapter and notes for Week 2 located in the Learning Activities area in Blackboard. Then answer the following questions:

(a) Briefly explain the difference between Θ (Theta) notation and big-O notation. Also provide the mathematical definitions of each.

(b) What is the a.symptotic.: complexity ( big-O) of the ibllowing code block? Briefly explain why.

Note: No programming is necessary for this problem. Just tell me what the big-O of the function, and provide a couple of sentences explaining how you arrived at the solution.

void myFunction(int n, int *a)

for (int i=0; i< n; i++) a[i] = 0;
}
for (int i=0; i< n; i++) {
for (int j=0; j < n; j++}
a[i] += a[j] + i + j;
for (int k=0; j < n; j++} a[j] += a[k] + 1 + j +
}
return;

Reference no: EM131206008

Questions Cloud

Perform a stock valuation prior : You have been asked to perform a stock valuation prior to the annual shareholders meeting next week. The two models you've selected to value the firm are 1) the dividend discount model and 2) the discounted cash flow model. Explain why the estimat..
Characteristics of foreign securities lead : 1) What characteristics of foreign securities lead to diversification benefits for American investors? 2) Will increasing integration of national capital markets reduce the benefits of international diversifications?
What logistical threats does the nation face : Demonstrate an understanding of how domestic and global terrorism threaten the logistics of the nominated organization. Discuss how these risks may be mitigated. Creatively synthesize current and past course material to devise solutions that balan..
Examine the key factors that influence the supply and demand : From the e-Activity, examine the key factors that influence the supply and demand of the selected good in general and Katrina's Candies specifically.
Implement the details of a recursive function : Perform an Internet search and provide a brief description (at least a paragraph with four to five sentences) of an example of a practical use for recursion - Briefly explain the difference between Θ (Theta) notation and big-O notation. Also provid..
Determine key factor that you believe to be most influential : Aside from maximizing profits, list the key factors that managers should consider when deciding whether or not to outsource offshore. Determine the key factors that you believe to be the most influential.
Determine the time constant of the circuit : Determine the time constant of the circuit when the switch is thrown into position 1. - Find the mathematical expression for the voltage across the capacitor after the switch is thrown into position 1.
What is the marginal rate of transformation impact : Without trade, the United States produces AND CONSUMES 32,500 units of clothing and 125,000 cans of soda.
Calculate what price katrinas candies should charge : Algebraically, determine what price Katrina's Candies should charge in order for the company to maximize profit in the short run. Determine the quantity that would be produced at this price and the maximum profit possible.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What is printed by the following program

What is printed by the following program?

  Service deliver to erica

At work one day, Erica Franz received 36packages. Speedy Delivery delivered three three times as many as Ralph's Express, while Ralph's Express delivered four more than Send Quick Package Service. How many packages did each service deliver to Erica..

  Reverse the order of the characters in the string

Write a program which will perform the following " using MARS - Assembly language"

  Set of nested for loops

Use a set of nested for loops to display the letters "R" and "B" in patterns as they might appear on a checkerboard.

  Are any values of x also illegal?

Have your program print an error message if n

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  Calculates the equivalent total number of seconds

The program should declare 4 variables, hours, minutes, seconds, and totalSeconds, all of type int. You may declare at most 1 additional variable for temporary usage. No other variable are allowed.

  Use structures to create c program to compute student record

Explain the following and give their suitable syntax. A pointer. Use structures to create C program to compute and store student records of class.

  Write a function that returns a pointer to an array

Write and show a function that takes an integer n and returns a pointer to an array of the first n cubes (0, 1, 8, 27, and so on).

  Design a module named getnumber which uses a reference

Design a module named getNumber which uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input in the reference parameter variable.

  Thenbspproblemwritenbspa programnbspthat translatesnbspto

thenbspproblemwritenbspa programnbspthat translatesnbspto and from morsenbspcode.nbspuse the curl librarynbspand a

  Write fibonacci function that calculates the nth number

The Fibonnacci numbers begin with the numbers 0 and 1 and have the property that each succeeding number is the sum of the two preceding numbers. For xample: 0,1,1,2,3,5,8,13,21,...etc. Write Fibonacci() function that calculates the n'th Fibonacci ..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd