Question

In: Computer Science

a. In your own words, define the concept of "Recursion" in terms of C++ programming. b....

a. In your own words, define the concept of "Recursion" in terms of C++ programming.

b. In your own words, define the concept of "infinite recursion".

c. In your own words, define "mutual recursion" as it pertains to C++ programming.

Solutions

Expert Solution

a.

Recursion:

The recursive function calls to itself and a terminate or base condition is specified which breaks the infinite execution of the recursive call. When the function call to itself then it works like a continue statement and the control goes to the starting of the function with updated argument value.

In a recursive program, the function call to itself and recursion is always applied to functions and the stack data structure is used in recursion for storing the intermediate value when each function call is made.

For example:

int fact(int n)
{
//base condition
if (n <= 1)
{
return 1;
}
else
{
return n*fact(n-1);
}
}

b.

As we can see in the above recursive function, two cases are mention:

  1. Base condition
  2. Recursive call

Base condition:

A terminate condition or base condition is specified which breaks the infinite execution of the recursive call.

Recursive Call:

The function will call to itself and this is known as a recursive call.

If the base condition is missing then infinite recursion will occur.

c.

Mutual Recursion:

Mutual recursion is recursion in which two recursive functions defined in terms of each other. The first function make a recursive call to the second function and the second function make a recursive call back to the first function.

For example:

int odd(int N)
{
   if (N == 0)
       return 0;
   else
       return even(N-1);
}

int even(int N)
{
   if(N == 0)
       return 1;
   else
       return odd(N-1);
}

The odd() function is calling even() function and even() function is calling odd() function.


Related Solutions

2. Define the following terms in your own words : a. Computer. b. Hardware (H/W). c....
2. Define the following terms in your own words : a. Computer. b. Hardware (H/W). c. Software (S/W). d. Input Devices. e. Output devices. f. Primary Memory. g. Peripheral device.
Define the following terms, in your own words, as they relate to GNSS positioning: a.Pseudorange, b....
Define the following terms, in your own words, as they relate to GNSS positioning: a.Pseudorange, b. Integer Ambiguity , c.Multipath
In your own words, define or explain the follow­ing terms or symbols: (a) mL; (b) % by mass; (c) °C; (d) density; (e) element.
In your own words, define or explain the follow­ing terms or symbols:(a) mL; (b) % by mass; (c) °C; (d) density; (e) element.
Q13.Define the following terms in your own words using 1 or 2 sentences : a)IGRT b)...
Q13.Define the following terms in your own words using 1 or 2 sentences : a)IGRT b) SRS c) SBRT a)GTV d) PTV e)BED b)4DCT g)rigid-body image registration
In your own words define and explain “marketing concept” and the “4P’s.” Provide an example of...
In your own words define and explain “marketing concept” and the “4P’s.” Provide an example of a company that uses one or both approaches. • Define “marketing” and “sales” and explain how they are different from one another. How are they dependent upon one another? • Does “marketing” have a function in church operations? Explain and support your answer. Generational trends lead to distinctly different attitudes, values, and behavioral patterns that must be considered when developing a market plan. •...
Step 1 Define terms. Explain the following terms in your own words in the discussion forum:...
Step 1 Define terms. Explain the following terms in your own words in the discussion forum: Positive correlation Negative correlation No correlation Step 2 Give real-world examples and post. Offer examples of the following: Two variables that you believe would share a positive correlation Two that you believe would be negatively correlated Two that would not be related at all
Question 1: In your own words define the terms and indicate whether they are a bond...
Question 1: In your own words define the terms and indicate whether they are a bond or interaction Term Definition Induced Dipole Ionic Hydrogen Bonding Polar Covalent Covalent Metallic Non-polar covalent Van der Waals Permanent Dipole Question 2: What is the ionic character of NaCl? What kind of bond is it and why?
Question 1: In your own words define the terms and indicate whether they are a bond...
Question 1: In your own words define the terms and indicate whether they are a bond or interaction Term Definition Induced Dipole Ionic Hydrogen Bonding Polar Covalent Covalent Metallic Non-polar covalent Van der Waals Permanent Dipole Question 2: What is the ionic character of NaCl? What kind of bond is it and why?
1) In your own words define “discretisation” and “degrees of freedom” in terms of the finite...
1) In your own words define “discretisation” and “degrees of freedom” in terms of the finite element method. a) Give the governing equation for a thermal analysis and briefly explain each term. Using this equation, describe the three basic modes of heat transfer and how they are included into an FE analysis. [Word limit: 200] b) What do the terms sensitivity, verification, and validation mean in regards to the accuracy of a finite element analysis and how are they utilised?
10.1 In your own words please define in a paragraph or less the following terms and...
10.1 In your own words please define in a paragraph or less the following terms and their relationship which each other: IT governance, IT Budget, Management of Role in IT initiatives.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT