Identify the base case.

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

1. Consider the following recursive function.

int mystery(int number)
{
if(number == 0)
return number;
else
return(number + mystery(number - 1));
}

a. Identify the base case.

b. Identify the general case.

c. What valid values can be passed as parameters to the function mystery?

d. If mystery(0) is a valid call, what is its value? If not, explain why.

e. If mystery(5) is a valid call, what is its value? If not, explain why.

f. If mystery(-3) is a valid call, what is its value? If not, explain why.

2. Consider the following recursive function:

void funcRec(int u, char v)
{
if(u == 0)
cout<<v;
else if(u == 1)
cout<<static_cast<char>(static_cast<int>(v) + 1);
else
funcRec(u - 1, v);
}

a. Identify the base case.

b. Identify the general case.

c. What is the output of the following statement? funcRec(5, 'A');

Reference no: EM13938229

Questions Cloud

Prepare the entry by green bay to record the delivery : Prepare the entry by Green Bay to record the delivery of 150 units during 2011. Wausau pays in cash upon delivery for units not covered by the deposit.
Prepare an additional detail claim : Prepare an additional detail claim in order to adjust the cost overrun. For example, under the part "d" instead of timber trusses client prefers steel trusses. It causes massive impact on rates whereas the provided BoQ doesn't have such items. In ..
Which medications would you anticipate holding : Prior to Mrs. Tell's 10am surgery, which medications will you administer and which medications would you anticipate holding? Please give the rationale for your answer.
Compute the warranty expense : Compute the warranty expense for 2009. What is the December 31, 2009, balance in the estimated warranty liability account? Prepare the entry to record the payment of the 2009 warranty claims.
Identify the base case. : What valid values can be passed as parameters to the function mystery?
Identify the factors affecting executive compensation : Identify the different stakeholder(s) to consider. Identify the factors affecting executive compensation. Describe the impact of unionization on wages
Ways information systems can improve our lives : What are some of the ways information systems can improve our lives?  What are some of the bene?ts organisations seek to achieve through using information systems?
What are the physiological challenges an organism : What are the physiological challenges an organism (such as a waterbug) might experience in a freshwater lake of the following conditions: depth of 200 m, water cold (approx 10 degrees celcius on surface), eutrophic, poor visibility, pH approx. 4?
What is the incremental profit associated with adding : What is the incremental profit associated with adding a round trip flight?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Design a class: pounds (type long) and shillings (type int)

Design a class: pounds (type long), shillings (type int), pence(type int) data items.

  Objectivein this assignment you read a list of employees

objectivein this assignment you read a list of employees from a csv file and convert them into corresponding objects.

  The imperial system of measurements

The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.

  Write a program that uses the class salariedemployee

Write a program that uses the class SalariedEmployee shown below. Your program is to define a class called Administrator, which is to be derived from the class SalariedEmployee. You are allowed to change private in the base class to protected. You..

  A class is derived from another one

In C++, when a class is derived from another one, you can specify the inheritance relationship as public, private or even protected. What are the main differences a between these types of inheritance in C++? How does a public inheritance differ from ..

  Extension of a filename

Modify your earlier program that found the extension of a filename. This time your program will identify a file name that is no longer that 12 characters and has one of five extensions that you specify (eg: .doc. .py, .html, .txt, .ps).

  Develop a global function customerinformation

Use a parameterized constructor to initialize data members - Develop a global function "CustomerInformation" that prints the customers information (number of dept each customer can handel). ( Use copy constructor).

  Explain the concept of arrays

n array is a powerful data structure in C++ that lets us keep track of lists of different types of information. They are quite flexible in that we can put almost anything we want into an array and then access it at a later time. Arrays have two ma..

  Customer details file in the configuration file

Display a message to the user to specify the path of the file in which the customer details are to be stored. Create the customer details file at the user-defined location. Create a configuration file and store the path of the customer details file i..

  Write main function to compute stress-strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads.

  Individual genes are substrings of a genome

Individual genes are substrings of a genome delineated by 3-element start and stop codons. Genes begin with the start codon ATG and end with one of the following 3 stop codons: TAG, TAA or TGA. Note that start codons can appear anywhere in the string..

  Program consisting of multiple objects

Write a program consisting of multiple objects which interact with each other by following appropriate design practices

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