Deck 14: Recursion

ملء الشاشة (f)
exit full mode
سؤال
A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Recursion can be a powerful tool for solving repetitive problems and is an important topic in upper-level computer science courses.
سؤال
A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion?

A) 1
B) 7
C) 8
D) 6
سؤال
When recursive methods directly call themselves, it is known as

A) direct recursion
B) indirect recursion
C) basic recursion
D) static recursion
سؤال
The recursive case does not require recursion so it stops the chain of recursive calls.
سؤال
__________ occurs when method A calls method B which in turn calls method
A)

A) Dynamic recursion
B) Linear recursion
C) Direct recursion
D) Indirect recusion
سؤال
The __________ is at least one case in which a problem can be solved without recursion.

A) recursive case
B) base case
C) termination point
D) pont of absolution
سؤال
Any problem that can be solved recursively can also be solved iteratively, with a loop.
سؤال
Like a loop, a recursive method must have which of the following?

A) a statement that increments the control variable
B) a control variable initialized to a starting value
C) some way to control the number of time it repeats
D) All of these
سؤال
Without a base case, a recursive method will call itself only once and stop.
سؤال
Which of the following problems can be solved recursively?

A) greatest common denominator
B) Towers of Hanoi
C) binary search
D) All of these.
سؤال
In the __________, we must always reduce the problem to a smaller version of the original problem.

A) partition case
B) base case
C) lessening case
D) recursive case
سؤال
A recursive method can have only one base case.
سؤال
In a recursive program, the number of times a method calls itself is known as

A) the call count
B) the cyclic identity
C) the method heap
D) the depth of recursion
سؤال
Whereas a recursive algorithm might result in faster execution time, the programmer might be able to design an iterative algorithm faster.
سؤال
A method that calls itself is a __________ method.

A) recursive
B) redundant
C) binary
D) derived
سؤال
Recursion is never absolutely required to solve a problem.
سؤال
The Towers of Hanoi is a mathematical game that is often used in computer science textbooks to illustrate the power of recursion.
سؤال
The recursive binary search algorithm is a good example of repeatedly breaking a problem down into smaller pieces until it is solved.
سؤال
The actions performed by the JVM that take place with each method call are sometimes referred to as

A) overhead
B) allocation
C) overflow
D) retention
سؤال
To use recursion for a binary search, what is required before the search can proceed?

A) The array must include only integers.
B) The array can only include numerical values.
C) The array must be sorted.
D) All of these are required.
سؤال
In the following code that uses recursion to find the greatest common divisor of a number, what is the base case?
public static int gcd(int x, int y)
{
If (x % y == 0)
Return y;
Else
Return gcd(y, x % y);
}

A) gcd(int x, int y)
B) if (x % y == 0)
Return y;
C) else
Return gcd(y, x % y);
D) Cannot tell from this code
سؤال
In the following code that uses recursion to find the factorial of a number, what is the base case?
private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}

A) factorial(int n)
B) if (n == 0)
Return 1;
C) else
Return n * factorial(n - 1);
D) Cannot tell from this code
سؤال
Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5?
private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}

A) 3
B) 4
C) 5
D) 6
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/24
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 14: Recursion
1
A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.
True
2
Recursion can be a powerful tool for solving repetitive problems and is an important topic in upper-level computer science courses.
True
3
A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion?

A) 1
B) 7
C) 8
D) 6
B
4
When recursive methods directly call themselves, it is known as

A) direct recursion
B) indirect recursion
C) basic recursion
D) static recursion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
5
The recursive case does not require recursion so it stops the chain of recursive calls.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
6
__________ occurs when method A calls method B which in turn calls method
A)

A) Dynamic recursion
B) Linear recursion
C) Direct recursion
D) Indirect recusion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
7
The __________ is at least one case in which a problem can be solved without recursion.

A) recursive case
B) base case
C) termination point
D) pont of absolution
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
8
Any problem that can be solved recursively can also be solved iteratively, with a loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
9
Like a loop, a recursive method must have which of the following?

A) a statement that increments the control variable
B) a control variable initialized to a starting value
C) some way to control the number of time it repeats
D) All of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
10
Without a base case, a recursive method will call itself only once and stop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following problems can be solved recursively?

A) greatest common denominator
B) Towers of Hanoi
C) binary search
D) All of these.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
12
In the __________, we must always reduce the problem to a smaller version of the original problem.

A) partition case
B) base case
C) lessening case
D) recursive case
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
13
A recursive method can have only one base case.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
14
In a recursive program, the number of times a method calls itself is known as

A) the call count
B) the cyclic identity
C) the method heap
D) the depth of recursion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
15
Whereas a recursive algorithm might result in faster execution time, the programmer might be able to design an iterative algorithm faster.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
16
A method that calls itself is a __________ method.

A) recursive
B) redundant
C) binary
D) derived
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
17
Recursion is never absolutely required to solve a problem.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
18
The Towers of Hanoi is a mathematical game that is often used in computer science textbooks to illustrate the power of recursion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
19
The recursive binary search algorithm is a good example of repeatedly breaking a problem down into smaller pieces until it is solved.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
20
The actions performed by the JVM that take place with each method call are sometimes referred to as

A) overhead
B) allocation
C) overflow
D) retention
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
21
To use recursion for a binary search, what is required before the search can proceed?

A) The array must include only integers.
B) The array can only include numerical values.
C) The array must be sorted.
D) All of these are required.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
22
In the following code that uses recursion to find the greatest common divisor of a number, what is the base case?
public static int gcd(int x, int y)
{
If (x % y == 0)
Return y;
Else
Return gcd(y, x % y);
}

A) gcd(int x, int y)
B) if (x % y == 0)
Return y;
C) else
Return gcd(y, x % y);
D) Cannot tell from this code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
23
In the following code that uses recursion to find the factorial of a number, what is the base case?
private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}

A) factorial(int n)
B) if (n == 0)
Return 1;
C) else
Return n * factorial(n - 1);
D) Cannot tell from this code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
24
Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5?
private static int factorial(int n)
{
If (n == 0)
Return 1;
Else
Return n * factorial(n - 1);
}

A) 3
B) 4
C) 5
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 24 في هذه المجموعة.