Question

Assume that the functions CS303 and UMKC have been defined as follows: int CS303(int n) {...

Assume that the functions CS303 and UMKC have been defined as follows:

int CS303(int n) {

     if (n == 0) {

           return 1;

     } else {

           return UMKC(2, CS303(n - 1));

     }

}

int UMKC(int n1, int n2) {

     if (n1 == 0) {

           return 0;

     } else {

           return n2 + UMKC(n1 - 1, n2);

     }

}

What is the value of CS303(4)?

Homework Answers

Answer #1

:

Answer: 16

OUTPUT:

I ADD TWO FUNCTIONS IN THE MAIN FUNCTION OF C LANGUAGE

AND EXECUTE;

TWO FUNCTIONS CALLS RECURSIVELY BASED ON THE ARGUMENTS VALUES

CODE:

#include <stdio.h>
int CS303(int n)
{
if (n == 0)
{
return 1;
} else
{
return UMKC(2, CS303(n - 1));
}
}

int UMKC(int n1, int n2)
{
if (n1 == 0) {
return 0;
}
else
{
return n2 + UMKC(n1 - 1, n2);
}
}
int main()
{
int val=CS303(4);
printf("%d",val);
return 0;
}

SCREENSHOT OF THE CODE:

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
Assume that the functions CS303 and UMKC have been defined as follows: int CS303(int n) {...
Assume that the functions CS303 and UMKC have been defined as follows: int CS303(int n) {      if (n == 0) {            return 1;      } else {            return UMKC(2, CS303(n - 1));      } } int UMKC(int n1, int n2) {      if (n1 == 0) {            return 0;      } else {            return n2 + UMKC(n1 - 1, n2);      } } What is the value of CS303(5)?
Assume that the functions CS303 and UMKC have been defined as follows: int CS303(int n) {...
Assume that the functions CS303 and UMKC have been defined as follows: int CS303(int n) { if (n <= 0) { return 1; } else { return UMKC(5, CS303(n - 5));      } } int UMKC(int n1, int n2) { if (n1 == 0) { return 0; } else { return n2 + UMKC(n1/5, n2);      } } What is the value of CS303(20)?
Given the following function: int bar(int n) {     if( n < 0 )         return...
Given the following function: int bar(int n) {     if( n < 0 )         return -2;     else if (n <= 1)         return 2;     else       return (3 + bar(n-1) + bar(n-2)); } What is returned by bar (4)? Show all the steps
int algorithm ( int n ) {    if (n == 0)           return 1; else...
int algorithm ( int n ) {    if (n == 0)           return 1; else { return 2 * algorithm(n-1);    } }
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)          ...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)           return true;        else           return false; } public static int Method(int[] numbers, int startIndex) { if(startIndex >= numbers.length)        return 0; if (isTrue(numbers[startIndex]))      return 1 + Method(numbers, startIndex + 1); else      return Method(numbers, startIndex + 1); } What is the final return value of Method() if it is called with the following parameters: numbers = {1, 2, 2, 3, 3,...
A.6 ... static int x = 1; int y = x * 2; void t1() {...
A.6 ... static int x = 1; int y = x * 2; void t1() {                 y++;                 cout << "x: " << x << " | y: " << y << endl;                 y += 1;                 x -= -1; } void t2() {                 int* x = &y;                 cout << "x: " << x << " | y: " << y << endl; } void t3() {                 int y = x;                 static int x...
DIRECTIONS: IMPLEMENT QuickSort and MergeSort. You have been provided: 1. Functions to perform Merge (for MergeSort)...
DIRECTIONS: IMPLEMENT QuickSort and MergeSort. You have been provided: 1. Functions to perform Merge (for MergeSort) and Partition (for QuickSort). 2. In class we discussed the body of the recursive functions, the "brakes" needed to stop the recursion. You are expected to develop 2 RECURSIVE programs: 1. Complete the bodies of the sort functions, MergeSort and QuickSort. 2. Complate the main that tests each function. - program should not read inputs - stock the program with multiple arrays (test cases)...
Given the following function:      int C(int n, int k)                  {              
Given the following function:      int C(int n, int k)                  {                     if (k= =0) return 1;                        else return (C(n-1, k-1) * n)/k;                                       } What type of function is this? Recursive or Iterative. Explain your answer.
Draw a program flow graph for the function below int binsearch(int x,int v[],int n) { int...
Draw a program flow graph for the function below int binsearch(int x,int v[],int n) { int low,high,mid; low=0; high=n-1; while(low<high) { mid = ( low + high ) / 2; if( x < v[mid]) high = mid - 1; else if ( x > v[mid]) low = mid + 1; else return mid; } return -1; }
What does the following function compute? Give an analysis of its complexity int fun1 (int n)...
What does the following function compute? Give an analysis of its complexity int fun1 (int n) { if (n == 0)     return 1; else      return fun1(n-1) + fun1(n-1); }
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT