What is the output of examplerecursion(3)

Assignment Help C/C++ Programming
Reference no: EM13938135

Question 1

In the backtracking algorithm, if it is determined that a partial solution would end in a dead end, then the algorithm ____.

1. terminates

2. restarts

3. removes the most recently added part and tries other possibilities

4. was designed incorrectly

Question 2

void decToBin(int num, int base)
{
if(num > 0)
{
decToBin(num/base, base);
cout<<num % base;
}
}

Question 3

Given the recursive function above, what is the result of decToBin(39, 2)?

1. 10111

2. 10011

3. 100111

4. 110111

Question 4

int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

Question 5

Which of the following function calls would result in the value 1 being returned?

1. func1(0, 1)

2. func1(1, 0)

3. func1(2, 0)

4. func1(1, 2)

Question 6

int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);

}

Question 7

What is the output of func2(2, 3)?

1. 2

2. 3

3. 5

4. 6

Question 8

int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);
}

Question 9

Which of the following statements about the code above is always true?

1. func2(m,n) = func2(n, m) for m >= 0

2. func2(m,n) = m * n for n >=0

3. func2(m,n) = m + n for n >=0

4. func2(m, n) = n * m for n >=0

Question 10

int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

Question 11

How many base cases are in the function above?

1. 0

2. 1

3. 2

4. 3

Question 12

int func3(int m, int n) {
if (m < n)
return 0;
else
return 1 + func3(m-n, n);
}

Question 13

What is the value of func3(9, 7), based on the code above?

1. 0

2. 1

3. 2

4. 7

Question 14

int rFibNum(int a,int b,int n)
{
if(n==1)
return a;
else if(n==2)
return b;
else
return rFibNum(a,b,n-1) + rFibNum(a,b,n-2);
}

Question 15

What is the limiting condition of the code above?

n >= 0

a >= 1

b >= 1

n >= 1

Question 16

int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

Question 17

What does the code above do?

1. Returns the cube of the number n

2. Returns the sum of the cubes of the numbers, 0 to n

3. Returns three times the number n

4. Returns the next number in a Fibonacci sequence

Question 18

int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

Question 19

What is the output of exampleRecursion(3) ?

1. 25

2. 32

3. 36

4. 42

Reference no: EM13938135

Questions Cloud

Identify and analyse the business global logistics : Your task is to identify and analyse the business's global logistics, supply chain channels, sustainability throughout the value chain and the associated linkages back to the theory you are studying in LB5230 - Managing Strategic Resources and Ope..
Independence using chi-squared distribution : In order to assess rates of faulty installation for home solar panel arrays, a sample of homes with recently installed arrays was examined by expert assessors and each array was graded as either "unsafe", "sub-standard" or "acceptable".
Prepare entries for yarnell electronic to record transaction : Yarnell Electronics sells computer systems to small businesses. Prepare entries for Yarnell Electronics to record these transactions.
Do you believe kohlbergs trends and findings are credible : Do you believe Kohlbergs trends and findings are credible? State whether you agree or disagree, and why. Offer your observation of where you think the moral barometer would hover in most large corporations in America today. Level 1, 2, or 3? Stage..
What is the output of examplerecursion(3) : Given the recursive function above, what is the result of decToBin(39, 2)
Accounting policies or estimates and impact thereof : You are required to collect the following information on your selected company for the most recent annual report you are able to obtain:
Discuss profiling as a legal tool of law enforcement : Discuss profiling as a legal tool of law enforcement. When might it be acceptable or even necessary to use race in forming a profile of a criminal or criminal activity
What is taxonomy : What is taxonomy? Explain in detail.
Why are some simple plants only found in damp places : Why are some simple plants only found in damp places. Why are flowering plants the most successful on this planet. What is the difference between reproduction in coniferous plants and in flowering plants.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Make the program as efficient as possible

Write a Forms application, using loops, that generates the following diamond pattern when the button is clicked. For your output, use a multi-line textbox with the TextAlign property set to Center. Make the program as efficient as possible! You ca..

  Create a friend class

Create a Friend class that contains a first name, last name, a birthday, and a telephone number. Create a Contacts class that contains an array of Friend as well as the owner's name and cell phone Number.

  Prepare a cc program that uses the pthread library to

prepare a cc program that uses the pthread library to create threads and mutexes to synchronize them. the program must

  Design, write, and test a program

Design, write, and test a program that represents some of the aspects of a student

  Performs a binary search instead of a linear search.

Modify the following program so it performs a binary search instead of a linear search. Use the selection sort algorithm to sort the array before the binary search is performed.

  Sum of all the numbers

Write a program that repeatedly asks a user to enter a number. The program will sum up all the number that the user keyed in. Terminate the program when the user enters -9, and display the sum of all the numbers entered by the user (exclude -9).

  Write program which inputs number of winning coupons

Write a program which inputs number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all off your coupons on candy bars first and remaining coupons on gumballs in c++.

  Create a program that allows a user to create a bank account

Create a program that allows a user to choose one of the main menu items - If User enters an option other than C, L, or Q, the program does not do anything and shows a message wrong option and displays the menu again.

  Program which opens a data file and displays its content

writing a C++ program which opens a data file and then displays its contents with line numbers. That is the program should display the number 1 and then the first line of the file, then the number 2 and the second line of the file, etc.

  Improvemented program

What does this program do and would you improve it?

  Describe what kind of architecture the new payroll

you have been tasked with building a payroll program for a large organization with offices spread across the united

  Represents the nth fibonacci number

Prove by induction that the number of nodes in the activation tree for the Fibonacci function is 2F(n + 1) - 1.

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