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

  Write a program that uses joptionpanes to perform

For example, if the distance of travel is 30 kilometers, the time of travel is 2 hours, then the speed is 30/2 = 15 (kilometers per hour).

  What problem arises as the lengths of the time slices

What problem arises as the lengths of the time slices in a multiprogramming system are made shorter and shorter?

  Design a calculator program that will add two numbers input

Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user. Your program design should contain the following

  Give the sequence of vertices

(a) Draw G. (b) Give the sequence of vertices visited using depth-first search starting a t vertex 1. (c) Give the sequence of vertices visited using breadth-first search starting at vertex 1.

  Program user to enter student names and final grades

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed.

  Snoopy cache systems and directory based systems

Illustrate how Snoopy Cache Systems and Directory Based Systems operate in the following scenario: Handraw the statuses of the three steps corresponding to the scenario for each system.

  An assembly program to determine the price of a car rental

an Assembly program to determine the price of a car rental

  What mechanism allows the overloaded subscript operator

What mechanism allows the overloaded subscript operator [] to be used on the left side of an assignment statement, like this: v[2] = 22?

  Write a program for keeping a course list

Write a program for keeping a course list for each student in a college. The information about each student should be kept in an object that contains the student's name and a list of courses completed by the student.

  Write a program that first prompts the user

Write a program that first prompts the user (repeatedly , if necessary) to supply a single digit(0,1,2..9) The program should repeatedly prompt the user for integer values until a sentinel value of 0 is entered to terminate the program.

  Show how this priority queue is affected by adding string

To tell if one element in ZooGraph has relation X to another element, you look for a path between them. Show whether the following statements are true, using the picture or adjacency matrix.

  Online shopping order and computes and outputs

Write a program that allows the user to input a total dollar amount for an online shopping order and computes and outputs the shipping cost based on the following schedule:

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