📄 6.txt
字号:
View Assessment Result: Multiple-Choice Quiz 6
Your performance was as follows:
1.
Consider the following definition of a recursive function ff in C++.
int ff( int n, int m )
{
if( n == 0 ) return m;
return ff( n - 1, m + 1 );
}
Which of the following characterizes the value returned by the call f(n,m)?
(a) The sum of m and n
(b) The product of m and n
(c) The greatest common divisor of m and n
(d) The least common multiple of m and n
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
2.
Consider the following definition of a recursive function ff.
int ff( int n )
{
if( n == 0 ) return 1;
return 2 * ff( n - 1 );
}
If n > 0, what is returned by ff( n )?
(a) n2
(b) 2 * n
(c) 2n
(d) log2 n
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
3.
Consider the following definition of a recursive function f.
bool f( int x )
{
if( (x & 1) == 1 ) return (x == 1);
return f( x >> 1 ); // right shift
}
The value returned by the call f(x) will determine whether the input x is
(a) odd
(b) even
(c) a power of 2
(d) a prime
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
4.
Consider the following definition of a recursive function f.
int f( int x )
{
if( x == 0 ) return 1;
return x * f( x - 1 );
}
The inputs for which f will terminate are all x such that x is
(a) non-negative
(b) unrestricted
(c) even
(d) odd
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
5.
What would be the consequences for algorithms if recursion were removed from C++?
(a) All algorithms could still be implemented, but often less elegantly.
(b) All algorithms could still be implemented, but the efficiency would often be catastrophically worse.
(c) Some algorithms could no longer be implemented.
(d) None
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
6.
Consider the following definition of a recursive function f.
int f( int x )
{
if( x == 0 ) return 1;
return x * f( x );
}
For which inputs x will the call f(x) terminate?
(a) For all inputs x
(b) For all even inputs x only
(c) For all odd inputs x only
(d) For x = 0 only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
7.
Which of the following is (are) true of recursive algorithms and the backtracking problem-solving technique?
Recursive algorithms implement backtracking by reducing a problem into smaller and smaller sub-problems.
Recursive algorithms cannot be used to implement backtracking.
Recursive algorithms that implement backtracking do not typically have a base case.
(a) I only
(b) None
(c) I and III only
(d) II only
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 3.2.2 in the course notes.
--------------------------------------------------------------------------------
8.
Which of the following is (are) true of the minimax strategy for deciding the optimal move in a two-person game?
It assumes that a human player will eventually make a mistake by playing a move that is not optimal.
It is commonly used with a backtracking algorithm.
(a) I and II
(b) None
(c) II only
(d) I only
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See Chapter 8, pages 308–310, in the course textbook.
--------------------------------------------------------------------------------
9.
Which of the following statements is (are) typical of divide and conquer algorithms?
Recursive function calls are used to divide a problem into smaller and smaller sub-problems.
Concurrent programming is used to divide the necessary processing between multiple processors.
(a) I and II
(b) None
(c) I only
(d) II only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 3.2.1 in the course notes.
--------------------------------------------------------------------------------
10.
A divide-and-conquer algorithm typically makes use of
(a) integer division
(b) iteration through looping
(c) floating-point division
(d) recursion
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See Chapter 8, pages 292–293, in the course textbook.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 30.00
? Copyright 2004 iCarnegie, Inc. All rights reserved.
View Assessment Result: Multiple-Choice Quiz 6
Your performance was as follows:
1.
Consider the function defined as follows.
int f( int n )
{
if( n == 0 ) return 0;
if( (n & 1) == 0 ) return f(n/2);
return f(n/2) + 1;
}
The value returned by the call f( 10 ); is
(a) 3
(b) 5
(c) 1
(d) 2
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
2.
Consider the following definition of a recursive function ff.
int ff( int n )
{
if( n == 0 ) return 1;
return 2 * ff( n - 1 );
}
If n > 0, what is returned by ff( n )?
(a) n2
(b) 2n
(c) log2 n
(d) 2 * n
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
3.
Consider the following definition of a recursive function f.
bool f( int x )
{
if( (x & 1) == 1 ) return (x == 1);
return f( x >> 1 ); // right shift
}
The value returned by the call f(x) will determine whether the input x is
(a) a power of 2
(b) even
(c) a prime
(d) odd
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
4.
What would be the consequences for algorithms if recursion were removed from C++?
(a) All algorithms could still be implemented, but the efficiency would often be catastrophically worse.
(b) None
(c) All algorithms could still be implemented, but often less elegantly.
(d) Some algorithms could no longer be implemented.
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See section 3.1.1 of the course notes.
--------------------------------------------------------------------------------
5.
How many calls to itself is a recursive function allowed to make?
(a) None
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -