?? 7.txt
字號:
View Assessment Result: Multiple-Choice Quiz 7
Your performance was as follows:
1.
Consider the following statement using the STL sort() routine.
sort( A.begin(), A.end(), f );
Which of the following most accurately describes the result of executing this statement?
(a) Container A is sorted using the function f for assignments.
(b) Container A is sorted by applying function f to its elements.
(c) Container A is sorted using sorting algorithm f.
(d) Container A is sorted using the Boolean valued function f for comparisons.
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
2.
Consider the following outline of a template sorting function.
template<class T> void sort( T a[], int n ) { ... }
For a given sorting algorithm S, which of the following is true about using this outline to implement S?
(a) It is a poor choice since it does not work with linked lists.
(b) It is a reasonable way to implement S.
(c) It is impossible since the algorithm cannot know how to compare two instances of type T.
(d) It is a poor choice since templates slow down sorting.
Correct answer is (b)
Your score on this question is: 10.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
3.
Which of the following search algorithms can be applied to unsorted data?
Linear search
Binary search
(a) II only
(b) None
(c) I and II
(d) I only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 4.1.1 in the course notes.
--------------------------------------------------------------------------------
4.
Which of the following statements about both arrays and linked lists is (are) true?
Direct element access using subscripts is supported in both the containers.
Both can be searched using binary search.
Elements of both the containers can be sorted.
(a) III only
(b) II only
(c) I, II, and III
(d) II and III only
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 4.1.1 of the course notes.
--------------------------------------------------------------------------------
5.
In the context of hashing, what is meant by a collision?
(a) The hash function returns a value larger than the table size.
(b) The insertion algorithm cannot find an empty slot in the table.
(c) Two key/value pairs have the same value.
(d) Two different keys hash to the same slot.
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
6.
Which of the following is true about a good hash function?
(a) It should produce apparently random values for given items.
(b) It should produce small outputs for small inputs.
(c) It should never output a prime number.
(d) It should only output prime numbers.
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
7.
Consider the following C++ code fragment.
for( int i = 0; i < n; i++ ) {
for( int j = 0; j < n; j++ ) {
for( int k = 0; k < n; k++ ) {
body;
}
}
}
If body executes in constant time, then the asymptotic running time that most closely bounds from above the performance of this code fragment is
(a) O(n3)
(b) O(n2)
(c) O(2n)
(d) O(n)
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 4.2.1 of the course notes.
--------------------------------------------------------------------------------
8.
Consider the following C++ code fragment.
for( int i = 0; i < n; i++ ) {
for( int j = 0; j < n/5; j++ ) {
body;
}
}
If body executes in constant time, then the asymptotic running time that most closely bounds from above the performance of this code fragment is
(a) O(n2)
(b) O(n)
(c) O(n log n)
(d) O(n3)
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 4.2.1 of the course notes.
--------------------------------------------------------------------------------
9.
The asymptotic running time that most closely bounds the performance of insertion sort on an input array with length n is
(a) O(2n)
(b) O(n2)
(c) O(n log n)
(d) O(n)
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.7.2 of the course notes.
--------------------------------------------------------------------------------
10.
The asymptotic running time of merge sort with an input array of length n is most closely bound from above by?
(a) O(n log n)
(b) O(n)
(c) O(2n)
(d) O(n2)
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 4.2.1 of the course notes.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 20.00
? Copyright 2004 iCarnegie, Inc. All rights reserved.
View Assessment Result: Multiple-Choice Quiz 7
Your performance was as follows:
1.
Consider the following statement using the STL sort() routine.
sort( A.begin(), A.end(), f );
Which of the following most accurately describes the result of executing this statement?
(a) Container A is sorted using the function f for assignments.
(b) Container A is sorted using the Boolean valued function f for comparisons.
(c) Container A is sorted using sorting algorithm f.
(d) Container A is sorted by applying function f to its elements.
Correct answer is (b)
Your score on this question is: 10.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
2.
Which of the following statements about arrays and linked lists is (are) true in the context of a sorting algorithm?
The sorting algorithm is asymptotically faster if the elements are in an array rather than a linked list.
For the algorithm to be implemented, direct element access must be supported in both the containers.
(a) II only
(b) None
(c) I only
(d) I and II
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 4.1.2 of the course notes.
--------------------------------------------------------------------------------
3.
Which of the following search algorithms can be applied to unsorted data?
Linear search
Binary search
(a) I only
(b) II only
(c) I and II
(d) None
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 4.1.1 in the course notes.
--------------------------------------------------------------------------------
4.
Consider a data set of 100 items. Which of the following is a search algorithm (are search algorithms) that could possibly examine 25 items in this set before succeeding?
Linear search
Binary search
(a) II only
(b) I and II
(c) None
(d) I only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 4.1.1 in the course notes.
--------------------------------------------------------------------------------
5.
Which of the following indicates the primary difficulty with hashing in general?
(a) Hash functions are hard to compute.
(b) Access in hash tables is slow.
(c) Collisions will occur.
(d) Hash tables take up a lot of memory.
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See section 4.1.3 of the course notes.
--------------------------------------------------------------------------------
6.
Suppose hash() is a hash function. The main idea behind hashing is to use a key k to store a value v in which position of a table?
(a) hash(k,v)
(b) hash(v)
(c) hash() (a random position computed by the hash function using k)
(d) hash(k)
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -