Deck 20: Recursion

ملء الشاشة (f)
exit full mode
سؤال
The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Indirect recursion means that a function calls itself n number of times and then processing of the function starts from the first call.
سؤال
If a recursive algorithm does not contain a base case, it

A) returns 0 and stops
B) returns False and stops
C) uses up all available stack memory, causing the program to crash
D) reaches the recursive case and stops
E) None of these
سؤال
When recursion is used on a linked list, it will always display the contents of the list in reverse order.
سؤال
Any algorithm that can be coded with recursion can also be coded with an iterative structure.
سؤال
In a recursive solution, the base case is always the first case to be called.
سؤال
When a recursive function directly calls itself, this is known as direct recursion.
سؤال
A recursive function cannot call another function.
سؤال
A __________ function is one that calls itself.

A) dynamic
B) static
C) validation
D) recursive
E) None of these
سؤال
When function A calls function B which, in turn, calls function A, this is known as

A) direct recursion
B) indirect recursion
C) function swapping
D) perfect recursion
E) None of these
سؤال
Like a loop, a recursive function must have some method to control the number of times it repeats.
سؤال
The __________ of recursion is the number of times a recursive function calls itself.

A) level
B) breadth
C) type
D) depth
E) None of these
سؤال
The __________ algorithm uses recursion to sort a list.

A) shell sort
B) QuickSort
C) binary sort
D) red/black sort
E) None of these
سؤال
A recursive function is designed to terminate when it reaches its

A) return statement
B) closing curly brace
C) last parameter
D) base case
E) None of these
سؤال
A problem can be solved with recursion if it can be broken down into successive smaller problems that are the same as the overall problem.
سؤال
To solve a problem recursively, you must identify at least one case in which the problem can be solved without recursion.
سؤال
All mathematical problems are designed to be more efficient using recursive solutions.
سؤال
The QuickSort algorithm works on the basis of

A) three sublists
B) two sublists and a pivot
C) two pivots and a sublist
D) three pivots
E) None of these
سؤال
Recursive algorithms are less efficient than iterative algorithms.
سؤال
The programmer must ensure that a recursive function does not become

A) a static function
B) a virtual function
C) an endless loop
D) a dynamic function
E) None of these
سؤال
How many times will the following function call itself if 5 is passed as the argument?
Void showMessage(int n)
{
If (n > 0)
{
Cout << "Good day!" << endl;
ShowMessage(n - 1);
}
}

A) 1
B) 4
C) 5
D) An infinite number of times
سؤال
The QuickSort algorithm was developed in 1960 by

A) Bjarne Stroustrup
B) Tony Gaddis
C) C.A.R. Hoare
D) C.M. Turner
E) None of these
سؤال
How many times will the following function call itself if 5 is passed as the argument?
Void showMessage(int n)
{
If (n > 0)
{
Cout << "Good day!" << endl;
ShowMessage(n + 1);
}
}

A) 1
B) 4
C) 5
D) An infinite number of times
سؤال
The QuickSort algorithm is used to sort

A) lists stored in arrays or linear linked lists
B) tree data structures
C) randomly-ordered files
D) All of these
E) None of these
سؤال
Select all that apply. Which of the following problems can be solved using recursion?

A) computing factorials
B) finding the greatest common divisor of two numbers
C) doing a Binary Search
D) multiplying two numbers
E) traversing a linked list
سؤال
The following code is an example of a __________ recursive algorithm. int myRecursion(int array[], int first, int last, int val)
{
Int num;
If (first > last)
Return -1;
Num = (first + last)/2;
If (array[num] == val)
Return num;
If (array[num] < val)
Return myRecursion(array, num + 1, last, val);
Else
Return myRecursion(array, first, num - 1, val);
}

A) Towers of Hanoi
B) QuickSort
C) binary search
D) doubly linked list
E) None of these
سؤال
The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is

A) returned
B) received
C) one
D) zero
E) None of these
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/27
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 20: Recursion
1
The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.
True
2
Indirect recursion means that a function calls itself n number of times and then processing of the function starts from the first call.
False
3
If a recursive algorithm does not contain a base case, it

A) returns 0 and stops
B) returns False and stops
C) uses up all available stack memory, causing the program to crash
D) reaches the recursive case and stops
E) None of these
C
4
When recursion is used on a linked list, it will always display the contents of the list in reverse order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
5
Any algorithm that can be coded with recursion can also be coded with an iterative structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
6
In a recursive solution, the base case is always the first case to be called.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
7
When a recursive function directly calls itself, this is known as direct recursion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
8
A recursive function cannot call another function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
9
A __________ function is one that calls itself.

A) dynamic
B) static
C) validation
D) recursive
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
10
When function A calls function B which, in turn, calls function A, this is known as

A) direct recursion
B) indirect recursion
C) function swapping
D) perfect recursion
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
11
Like a loop, a recursive function must have some method to control the number of times it repeats.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
12
The __________ of recursion is the number of times a recursive function calls itself.

A) level
B) breadth
C) type
D) depth
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
13
The __________ algorithm uses recursion to sort a list.

A) shell sort
B) QuickSort
C) binary sort
D) red/black sort
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
14
A recursive function is designed to terminate when it reaches its

A) return statement
B) closing curly brace
C) last parameter
D) base case
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
15
A problem can be solved with recursion if it can be broken down into successive smaller problems that are the same as the overall problem.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
16
To solve a problem recursively, you must identify at least one case in which the problem can be solved without recursion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
17
All mathematical problems are designed to be more efficient using recursive solutions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
18
The QuickSort algorithm works on the basis of

A) three sublists
B) two sublists and a pivot
C) two pivots and a sublist
D) three pivots
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
19
Recursive algorithms are less efficient than iterative algorithms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
20
The programmer must ensure that a recursive function does not become

A) a static function
B) a virtual function
C) an endless loop
D) a dynamic function
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
21
How many times will the following function call itself if 5 is passed as the argument?
Void showMessage(int n)
{
If (n > 0)
{
Cout << "Good day!" << endl;
ShowMessage(n - 1);
}
}

A) 1
B) 4
C) 5
D) An infinite number of times
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
22
The QuickSort algorithm was developed in 1960 by

A) Bjarne Stroustrup
B) Tony Gaddis
C) C.A.R. Hoare
D) C.M. Turner
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
23
How many times will the following function call itself if 5 is passed as the argument?
Void showMessage(int n)
{
If (n > 0)
{
Cout << "Good day!" << endl;
ShowMessage(n + 1);
}
}

A) 1
B) 4
C) 5
D) An infinite number of times
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
24
The QuickSort algorithm is used to sort

A) lists stored in arrays or linear linked lists
B) tree data structures
C) randomly-ordered files
D) All of these
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
25
Select all that apply. Which of the following problems can be solved using recursion?

A) computing factorials
B) finding the greatest common divisor of two numbers
C) doing a Binary Search
D) multiplying two numbers
E) traversing a linked list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
26
The following code is an example of a __________ recursive algorithm. int myRecursion(int array[], int first, int last, int val)
{
Int num;
If (first > last)
Return -1;
Num = (first + last)/2;
If (array[num] == val)
Return num;
If (array[num] < val)
Return myRecursion(array, num + 1, last, val);
Else
Return myRecursion(array, first, num - 1, val);
}

A) Towers of Hanoi
B) QuickSort
C) binary search
D) doubly linked list
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
27
The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is

A) returned
B) received
C) one
D) zero
E) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 27 في هذه المجموعة.