Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My answers NEED to be in C++. Not C. Not C#. Not Java. Answers in these language

ID: 3562905 • Letter: M

Question

 My answers NEED to be in C++. Not C. Not C#. Not Java. Answers in these languages will be ingnored.  Recursion Exercises  1. Recursion is an example of  a. Selection  b. a data structure  c. repetition  d. data-flow programming   2. A void function can be recursive, but a value returning function cannot  (True or False)   3. When a function is called recursively, the arguments and automatic local variables of the calling version are saved until its execution is resumed.  (True or False)   4.Given the recursive formula F(n) = - F(n-2), with base case F(0) = 1, where are the values of F(4), F(6) and F(5)? If any of the values are undefined, say so    F(4) =    F(6) =    F(5) =     5.What algorithm errors lead to infinite recursion?    6.What control structure appears most commonly in a recursive function?   7.What is the name of the memory area used by the computer system to store a functions parameters and automatic local variables?  
 8.Given the following input data    ABCDE     What is the output of the following program?   #include   using namespace std;  void Rev();  int main()  {                 Rev();                 cout<       cout<< ch; Rev();    }  
 }   10.Given the following input:   15 23 21 19   What is the output of the following program ?   #include   using namespace std;  void PrintNums();  int main()  {     PrintNums();     cout<>n;  if (cin)    {         cout<< n<<

Explanation / Answer

1. Recursion is an example of
   a. Selection
   b. a data structure
   c. repetition
   d. data-flow programming
  
Answer: c. repetition

2. A void function can be recursive, but a value returning function cannot
(True or False)

Answer: False ,Since a value returning function also recursive

3. When a function is called recursively, the arguments and automatic local variables of the calling version are saved until its execution is resumed. (True or False)

Ans : True, All the arguments and local variables are stored in stack.

4.Given the recursive formula F(n) = - F(n-2), with base case F(0) = 1, where are the values of F(4), F(6) and F(5)? If any of the values are undefined, say so

   F(4) =   
   F(6) =   
   F(5) =   

Answer:
       F(0) =1
       F(2) = - F(2-2) = - F(0) = -(1) = -1
       F(4) = - F(4-2) = - F(2) = -(-1) = 1
       F(6) = - F(6-2) = - F(4) = - (1) = -1
       F(5) = - F(5-2) = - F(3) = - F(3-2) = - F(1) = undifined since F(1) we dont have value

5.What algorithm errors lead to infinite recursion?

Answer:
      
       The recusive function which contains iterative statements like for, while and do while loops
       leads to error.

      
6.What control structure appears most commonly in a recursive function?

Answer:
You must use compound statements such as if , nested if, if else ladder in recursive functions.

7.What is the name of the memory area used by the computer system to store a functions parameters and automatic local variables?

Answer :

Initially all function parameters and automatic local variables stored in stack. which are intern stored in Operating System Heap Memory

8.Given the following input data

ABCDE

What is the output of the following program?

#include
using namespace std;
void Rev();
int main()
{
Rev();
cout< cout<< ch;
Rev();
}
}

Answer :
           EDCBA


10.Given the following input:

15 23 21 19

What is the output of the following program ?

#include
using namespace std;
void PrintNums();
int main()
{
PrintNums();
cout<>n;
if (cin)
{
cout<< n<<

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote