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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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