Recognize the the base case

Assignment Help Computer Engineering
Reference no: EM1332005

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.

8. 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: EM1332005

Questions Cloud

Explain efas and ifas table : Using the Vermont Teddy Bear Company, develop IFAS & EFAS tables. - Include info on the scanning process.
Characteristics make diversity training most effective : Discuss what characteristics make diversity training most effective along with at least three different approaches to diversity training.
Explain possible business scenario and the different systems : Explain possible business scenario and the different systems
Participation of stakeholders effect cultural change : How do the participation / commitment of all stakeholders' effect cultural change? And how would it fit into your vision of running a large vs. a single vessel?
Recognize the the base case : What valid values could be passed as parameters to the function mystery.
Explain online payment system of books dotcom : Explain online payment system of books dotcom
Describing the fictional public organizations : Create and describe two fictional public organizations.Specifically, in terms of organizational structure, how are the two organizations similar? Explain in detail.
Write a memo to your training manager : Write a memo (essay) to your training manager, Manager Greg, outlining - two learning theories you would consider as 'best practices'
Pr and international politics intertwined : How are PR and international politics intertwined? How does PR influence the economy in various countries?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Explaining arp command

The arp command: arp -s InetAddr EtherAddr enables you to manually add an entry to ARP cache which resolves the IP address InetAddr to the physical address EtherAddr.

  Make a heading that contains the name of the software

discuss a specific virus software, its advantages and disadvantages. make a heading that contains the name of the software you are reviewing. It should be about half-page or less.

  Write down a program to test class rectangle

make a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has methods that calculate the perimeter and the area of the rectangle

  Imagine that a doubly linked list "header"

Assume that a doubly linked list "header" stores the elements of a priority queue. make use of the function pop(), which deletes the element with the largest value from the list (priority queue).

  Show how to build a j-k flip-flop

express how to build a J-K flip-flop using a T flip-flop with enable and combinational logic.

  How to create a driver file theaterreservationdriver

use a simple seat reservation system for a theater in C++. The seats in the theater will be represented with a two dimensional array. The closer the seats are to the stage, the more expensive the seats are. Moreover, within a row, the seats at the..

  Dns servers and dhcp servers

Assume that both the DNS servers and the DHCP servers send your client PC and IP addresses. Write down the differences between these two addresses.

  Why organization that meets the company''s specifications

A software application has been delivered to your organization that meets the company's specifications. Using associated examples, describe problems which may arise when it is installed and used in your organization.

  Research for a voip solution

In the future, Klamath’s separate the voice network will be dismantled. All the voice, data, and video traffic will traverse Metro Ethernet network.

  Z-transformation and fourier transformation

Find the z-transform and the Fourier transform of x(n). Find the N-point DFT of x (n) for N=50,10 and 5.

  Compute the integer part of the quotient

Calculate an integer remainder when integer a is divided by integer b.

  Exploring substantial component of information security

Explain the weaknesses in the controls? Specify whether there exist any new or upgraded access controls being considered? Let us explore this substantial component of the information security.

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