Exam 3: Recursion: the Mirrors

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

What are the two base cases for a recursive binary search algorithm?

Free
(Essay)
4.7/5
(37)
Correct Answer:
Verified

The two base cases are:
-first > last
-value == anArray[mid]
(where first is the index of the first item in the array,last is the index of the last item in the array,and mid is the midpoint of the array).

The number of ways to choose k out of n things is ______.

Free
(Multiple Choice)
4.9/5
(27)
Correct Answer:
Verified

C

An iterative solution involves loops.

Free
(True/False)
4.7/5
(36)
Correct Answer:
Verified

True

The midpoint of a sorted array can be found by ______,where first is the index of the first item in the array and last is the index of the last item in the array.

(Multiple Choice)
4.8/5
(34)

What is the base case for the recursive solution to the Towers of Hanoi problem?

(Essay)
4.9/5
(33)

When is the base case value == anArray[mid] (where mid is the midpoint of the array)reached in a recursive binary search algorithm?

(Essay)
4.8/5
(30)

What is a pivot item?

(Essay)
4.9/5
(36)

An iterative method always calls itself.

(True/False)
4.9/5
(27)

Which of the following is a precondition for a method that accepts a number n and computes the nth Fibonacci number?

(Multiple Choice)
4.9/5
(36)

A recursive solution can have more than one base cases.

(True/False)
4.8/5
(44)

A recursive binary search algorithm always reduces the problem size by ______ at each recursive call.

(Multiple Choice)
4.9/5
(37)

The factorial of n is equal to ______.

(Multiple Choice)
5.0/5
(31)

Which of the following is a base case for a recursive binary search algorithm? (first is the index of the first item in the array,last is the index of the last item in the array,and mid is the midpoint of the array).

(Multiple Choice)
4.9/5
(37)

Suppose a program contains a recursive method findFibonacci(int n),which computes the n-th Fibonacci number.Even if we know that a client method will never call findFibonacci( )with the values 1 or 2 as arguments,why does the implementation of findFibonacci( )still need to have base cases?

(Essay)
4.8/5
(48)

In a recursive solution,the ______ terminates the recursive processing.

(Multiple Choice)
4.9/5
(35)

Why does the Fibonacci sequence have two base cases? In other words,would it be possible to write a correct recursive Fibonacci method that has only one base case?

(Essay)
4.7/5
(33)

A recursive method that computes the number of groups of k out of n things has the precondition that ______.

(Multiple Choice)
4.9/5
(42)

In the recursive solution to the kth smallest item problem,the problem size decreases by ______ at each recursive call.

(Multiple Choice)
4.8/5
(31)

In the Fibonacci sequence,which of the following integers comes after the sequence 1,1,2,3?

(Multiple Choice)
4.9/5
(33)

What are the two factors which contribute to the inefficiency of some recursive solutions?

(Essay)
4.7/5
(37)
Showing 1 - 20 of 60
close modal

Filters

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