Deck 11: Recursion

ملء الشاشة (f)
exit full mode
سؤال
All recursive methods have a/an ____________ equivalent method.

A)Iterative
B)Selective
C)Inherited
D)None of the above
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A method definition that includes a call to itself is said to be recursive.
سؤال
The portion of memory in which a recursive computation is stored is called a/an:

A)stack frame
B)activation record
C)all of the above
D)none of the above
سؤال
A recursive solution can be preferable to an iterative solution because:

A)recursive method calls are faster than iterative looping
B)recursive solutions may be easier to understand than iterative ones
C)recursion uses less memory than iteration
D)iteration should be avoided.
سؤال
Pick the best answer

A)Recursive methods may include a recursive call
B)Recursive methods may not use iteration
C)Recursive methods must include a recursive call
D)none of the above
سؤال
Recursion is:

A)the ability of a program to repeat a block of code
B)the ability of a method to call itself
C)the ability of a method to call smaller methods
D)the ability of a method to implement factorials
سؤال
The stack is a ________________ data structure.

A)first in - first out
B)last in - last out
C)last in - first out
D)none of the above
سؤال
A recursive method is one that:

A)Returns a value
B)Initializes a set of variables
C)Returns no value
D)Invokes itself
سؤال
During recursion,if the stack attempts to grow beyond its limit,a _____________ occurs.

A)Stack underflow
B)Stack overflow
C)Recursive underflow
D)Recursive overflow
سؤال
What is the value returned when the integer 5 is the argument to the factorial method?

A)15
B)50
C)100
D)120
سؤال
When defining recursive void methods you should:

A)Ensure there is no infinite recursion.
B)Ensure that each stopping case performs the correct action for that case.
C)Ensure that if all recursive calls perform their actions correctly,then the entire case performs correctly.
D)All of the above
سؤال
A base case must include a recursive call.
سؤال
The following code for the method factorial)applies to the next two questions: public static double factorial double n)
{
If n == 0)
{
Return 1;
}
Else
{
Return n * factorialn-1);
}
}
What is the value returned when the integer 3 is the argument to the factorial method?

A)2
B)4
C)6
D)8
سؤال
The underlying data structure used by the computer during recursion is a:

A)queue
B)linked list
C)tree
D)stack
سؤال
When a recursive call is encountered,computation is temporarily suspended;all of the information needed to continue the computation is saved and the recursive call is evaluated.
سؤال
Infinite recursion:

A)will happen when there is no base case
B)will not happen when there is a base case
C)will not happen if we use subproblems
D)none of the above
سؤال
When defining recursive valued methods you should:

A)Ensure there is no infinite recursion.
B)Ensure each stopping case returns the correct value for that case.
C)Ensure that the final value returned by the method is the correct value.
D)All of the above
سؤال
The order of magnitude of the binary search algorithm is:

A)linear
B)exponential
C)logarithmic
D)quadratic
سؤال
Regarding recursion,if a base case is never reached the result is:

A)infinite recursion
B)iteration
C)termination
D)all of the above
سؤال
All recursive methods must have a/an:

A)starting case
B)intermediate case
C)stopping case
D)none of the above
سؤال
The binary search algorithm is extremely slow compared to an algorithm that simply tries all array elements in order.
سؤال
What is a base case?
سؤال
Write a recursive method to compute the power of x< sup >n< /sup > for non-negative n.
سؤال
Write a recursive method to compute the factorial of a number.
سؤال
Activation records are used to implement recursion.
سؤال
The binary search algorithm has worst-case running time that is logarithmic.
سؤال
How does the computer system handle a recursive method call?
سؤال
Write an iterative method to compute the power of x< sup >n< /sup > for non-negative n.
سؤال
Explain the concept of divide and conquer.
سؤال
A recursive method must never return a value.
سؤال
Binary search is a divide and conquer algorithm.
سؤال
Explain how a sequential search works.
سؤال
Write a recursive method to print a string backwards.
سؤال
Explain how the binary search works.
سؤال
Write an iterative method to print a string backwards.
سؤال
A recursively written method will usually run slower and use more storage than an equivalent iterative version.
سؤال
A stack is a last-in/first-out memory structure.
سؤال
To keep track of recursion most computer systems us a structure called a queue.
سؤال
What are the criteria you must consider when formulating a recursive solution?
سؤال
Write an iterative method to compute the factorial of a number.
سؤال
What is an activation record?
سؤال
What are two factors that contribute to the inefficiency of some recursive solutions?
سؤال
What are the two base cases for a recursive binary search algorithm?
سؤال
What is a stack overflow?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 11: Recursion
1
All recursive methods have a/an ____________ equivalent method.

A)Iterative
B)Selective
C)Inherited
D)None of the above
A
2
A method definition that includes a call to itself is said to be recursive.
True
3
The portion of memory in which a recursive computation is stored is called a/an:

A)stack frame
B)activation record
C)all of the above
D)none of the above
C
4
A recursive solution can be preferable to an iterative solution because:

A)recursive method calls are faster than iterative looping
B)recursive solutions may be easier to understand than iterative ones
C)recursion uses less memory than iteration
D)iteration should be avoided.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
5
Pick the best answer

A)Recursive methods may include a recursive call
B)Recursive methods may not use iteration
C)Recursive methods must include a recursive call
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
6
Recursion is:

A)the ability of a program to repeat a block of code
B)the ability of a method to call itself
C)the ability of a method to call smaller methods
D)the ability of a method to implement factorials
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
7
The stack is a ________________ data structure.

A)first in - first out
B)last in - last out
C)last in - first out
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
8
A recursive method is one that:

A)Returns a value
B)Initializes a set of variables
C)Returns no value
D)Invokes itself
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
9
During recursion,if the stack attempts to grow beyond its limit,a _____________ occurs.

A)Stack underflow
B)Stack overflow
C)Recursive underflow
D)Recursive overflow
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
10
What is the value returned when the integer 5 is the argument to the factorial method?

A)15
B)50
C)100
D)120
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
11
When defining recursive void methods you should:

A)Ensure there is no infinite recursion.
B)Ensure that each stopping case performs the correct action for that case.
C)Ensure that if all recursive calls perform their actions correctly,then the entire case performs correctly.
D)All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
12
A base case must include a recursive call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
13
The following code for the method factorial)applies to the next two questions: public static double factorial double n)
{
If n == 0)
{
Return 1;
}
Else
{
Return n * factorialn-1);
}
}
What is the value returned when the integer 3 is the argument to the factorial method?

A)2
B)4
C)6
D)8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
14
The underlying data structure used by the computer during recursion is a:

A)queue
B)linked list
C)tree
D)stack
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
15
When a recursive call is encountered,computation is temporarily suspended;all of the information needed to continue the computation is saved and the recursive call is evaluated.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
16
Infinite recursion:

A)will happen when there is no base case
B)will not happen when there is a base case
C)will not happen if we use subproblems
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
17
When defining recursive valued methods you should:

A)Ensure there is no infinite recursion.
B)Ensure each stopping case returns the correct value for that case.
C)Ensure that the final value returned by the method is the correct value.
D)All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
18
The order of magnitude of the binary search algorithm is:

A)linear
B)exponential
C)logarithmic
D)quadratic
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
19
Regarding recursion,if a base case is never reached the result is:

A)infinite recursion
B)iteration
C)termination
D)all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
20
All recursive methods must have a/an:

A)starting case
B)intermediate case
C)stopping case
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
21
The binary search algorithm is extremely slow compared to an algorithm that simply tries all array elements in order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
22
What is a base case?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
23
Write a recursive method to compute the power of x< sup >n< /sup > for non-negative n.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
24
Write a recursive method to compute the factorial of a number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
25
Activation records are used to implement recursion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
26
The binary search algorithm has worst-case running time that is logarithmic.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
27
How does the computer system handle a recursive method call?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
28
Write an iterative method to compute the power of x< sup >n< /sup > for non-negative n.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
29
Explain the concept of divide and conquer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
30
A recursive method must never return a value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
31
Binary search is a divide and conquer algorithm.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
32
Explain how a sequential search works.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
33
Write a recursive method to print a string backwards.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
34
Explain how the binary search works.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
35
Write an iterative method to print a string backwards.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
36
A recursively written method will usually run slower and use more storage than an equivalent iterative version.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
37
A stack is a last-in/first-out memory structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
38
To keep track of recursion most computer systems us a structure called a queue.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
39
What are the criteria you must consider when formulating a recursive solution?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
40
Write an iterative method to compute the factorial of a number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
41
What is an activation record?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
42
What are two factors that contribute to the inefficiency of some recursive solutions?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
43
What are the two base cases for a recursive binary search algorithm?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
44
What is a stack overflow?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.