Exam 13: Recursion

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Would you recommend using recursion or iteration in setting up a program for moving pallets of cargo off a ship? Justify your answer.

(Essay)
4.9/5
(32)

What is gcd?

(Multiple Choice)
4.8/5
(30)

The factorial method returns the factorial of n as a(n):

(Multiple Choice)
4.8/5
(32)

Recursive methods can be defined as static or nonstatic.

(True/False)
4.9/5
(42)

Why would you probably not want to write a program to find the even numbers from 1 to 20?

(Essay)
4.7/5
(38)

The factorial of 5 is 120.

(True/False)
4.7/5
(41)

In the body of a __________ method, there is a call to the method itself.

(Multiple Choice)
4.9/5
(43)

The formula that reduces the size of the problem is called the general case.

(True/False)
4.7/5
(39)

A Euclidian algorithm finds the gcd of two positive integers a and b. If the two parameters of the method are dividend and divisor, identify when you will have reached the base case.

(Essay)
4.8/5
(34)

The idea of recursion is to __________ the size of the problem at each step so that we eventually reach an easy-to-solve problem.

(Short Answer)
4.7/5
(40)

Solve the factorial of 4. Show your work.

(Short Answer)
4.9/5
(37)

You are using a binary search algorithm to search a sorted array for a given value. Organize the steps in defining bases cases and the general case by listing the order in which they should occur. 1) Assuming that the array is not empty, formulate the general case to search both higher and lower for the value, making a recursive call to our search method. 2) Define the base case such that if the value of the middle element is the value we seek, it will return its index. 3) Return -1 when the array is empty (i.e., a base case is reached). 4) Continue searching; the part of the array being searched will shrink until it is empty.

(Short Answer)
4.8/5
(40)

What will happen if you code for only one base case when there are two or more base cases?

(Multiple Choice)
4.9/5
(34)

Binary search (recursive or iterative) applies to:

(Multiple Choice)
4.8/5
(35)

In this chapter, source files are provided to complete programming activities. Theorize why these files are provided.

(Essay)
4.7/5
(46)

Provide the missing code in line 19 of this code segment. 15 if ( dividend % divisor == 0 ) // base case 16 { 17 System.out.println( "\nbase case reached, returning " 18 + divisor + "\n" ); 19 // Insert missing code here 20 } 21 else // general case

(Short Answer)
4.8/5
(31)

Justify writing pseudocode before writing the Java code.

(Essay)
4.9/5
(38)

The easy-to-solve problem resulting from recursion is called the __________ case.

(Short Answer)
4.8/5
(42)

Identify what must be changed to make this a true statement: To search a sorted array for a given value, you must define a base case to reduce the size of the problem and general cases to implement the base case.

(Essay)
5.0/5
(42)
Showing 41 - 59 of 59
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)