Question

Explain following terms .. a. Recursive function b. Base case of recursion      IN C LANGUAGE

Explain following terms ..
a. Recursive function
b. Base case of recursion
     IN C LANGUAGE

Homework Answers

Answer #1

a. Recursive function:

A recursive function is a function that calls it self.

Example code:

int f(n)
{
    if(n==1)
    {
       return 1;
    }
    else
    {
      return n+f(n-1)
    }
}

b.Base case of recursion:

Base case of recursion is the case at which recursive function terminates. Any recursive functionshould have to end at some point and recursive function executes till it reaches the base case.

In the above example the below one is the base case of recursive function.

if(n==1)

{

return 1;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Draw a Recursion Tree and solve for the complexity of the following recursive function T(n) =...
Draw a Recursion Tree and solve for the complexity of the following recursive function T(n) = T(n/2) + log(n)
The language is C. What is function(9)? Use a recursion tree to find the answer. int...
The language is C. What is function(9)? Use a recursion tree to find the answer. int function(int n) {                 If (n<=1)                                 return 1;                 If (n%2==0)                                 return f(n/2);                 return f(n/2) + f((n/2)+1); }
this assignment is about solving problems using recursion. For each question, write a recursive function that...
this assignment is about solving problems using recursion. For each question, write a recursive function that solves the problem asked in that question. Your solutions don't have to be efficient, but they do have to use recursion in a non-trivial way. Put all your code in a file called a9.py. Write a recursive function is_palindrome(s) that returns True or False depending on whether s is a palindrome. This is equivalent to returning s == s[::-1]. Write a recursive function find_min(a)...
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const...
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const char* str2) which returns the sum of strlen(str1) and strlen(str2). You can assume that strlen(str2) is always strictly greater than strlen(str1) (strlen(str2) > strlen(str1)). You MAY NOT use any function from string.h. You MAY NOT use any square brackets([]) or any type of loops in function.
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
Write in Racket Language Write a recursive Racket function "sum" that takes two integers as parameters,...
Write in Racket Language Write a recursive Racket function "sum" that takes two integers as parameters, each greater or equal to zero, and evaluates to their sum. In this problem, you must use the built-in functions "add1" and "sub1" and may not use the built-in functions "+" or "-". For example, (sum 2 3) should evaluate to 5. Note: (add1 5) evaluates to 6 and (sub1 4) evaluates to 3. Hint: like you saw in the "append" lecture, treat one...
Write in a c++ recursion function to prints the digits in reverse order using a recursion...
Write in a c++ recursion function to prints the digits in reverse order using a recursion function. Input: 23567 Output: 76532
In LISP, write a recursive function that takes an integer n and returns the summation of...
In LISP, write a recursive function that takes an integer n and returns the summation of n and all positive integers preceding it. ; e.g., passing 5 will return 15, which is 1+2+3+4+5. I have the worst skill when it comes to creating recursion in the LISP programming language. Any help at all would be appreciated.
Question Recursive Maximum: In this question you must develop and use a recurive function to find...
Question Recursive Maximum: In this question you must develop and use a recurive function to find the maximum value in array of integers. Complete the C program, Maximum.c, by implementing the recursive function maximumValue, and the regular function max, and completing the main function using the comments provided. Open the file Maximum.c, complete, compile and run it. When you are sure it is correct, include the c file in your final submission. Note that the function max is not recursive....
(Recursion) The function to be used in the calculation of binomial numbers, C (n, k): Express...
(Recursion) The function to be used in the calculation of binomial numbers, C (n, k): Express the recursion definition. Give the pseudo-code of the appropriate algorithm.(I would appreciate it if you explain all the questions in an explanatory way.)