📄 multiple-choice quiz 5.txt
字号:
Total score: 80.00
1.
Consider the following C++ program segment, which uses the STL.
stack<int> S;
S.push(123);
S.push(456);
cout << S.pop() << endl;
Which of the following accurately describes what, if anything, fails in the segment?
(a) A compilation error occurs because pop does not return a value.
(b) An execution error occurs because pop is a private member function.
(c) An execution error occurs because an STL stack has no member function pop.
(d) Nothing is wrong with the segment.
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.4.2 of the course notes.
--------------------------------------------------------------------------------
2.
Differences between the STL adapter queue and the STL container deque include which of the following?
queue provides support for iterators, whereas deque does not.
queue provides access to only the first and last elements in a collection, whereas deque permits access to an entire collection.
(a) I and II
(b) None
(c) I only
(d) II only
Correct answer is (d)
Your score on this question is: 10.00
Feedback:
See section 2.4.2 in the course notes.
--------------------------------------------------------------------------------
3.
The queue adapter interface in the C++ Standard Template Library contains which of the following member functions?
push
pop_back
(a) II only
(b) I and II
(c) None
(d) I only
Correct answer is (d)
Your score on this question is: 10.00
Feedback:
See section 2.4.2 in the course notes.
--------------------------------------------------------------------------------
4.
Which of the following operations typically removes an item from a stack?
(a) empty
(b) top
(c) pop
(d) push
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See Chapter 7, pages 233–234, in the course textbook.
--------------------------------------------------------------------------------
5.
Which of the following statements is (are) true about stacks?
Elements are inserted and deleted in last-in-first-out order.
Stacks can be implemented using linked lists.
Stacks can be implemented using arrays.
(a) I, II, and III
(b) II and III only
(c) I and III only
(d) I and II only
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.4.1 of the course notes.
--------------------------------------------------------------------------------
6.
Which of the following is not a basic operation that can be performed on a queue?
(a) Removing an item from the front of the queue
(b) Inserting an item at the back of the queue
(c) Accessing an item from the front of the queue
(d) Inserting an item into the second position of the queue
Correct answer is (d)
Your score on this question is: 10.00
Feedback:
See Chapter 7, page 236, in the course textbook.
--------------------------------------------------------------------------------
7.
Typical implementations for which of the following STL containers store elements contiguously in memory?
vector
list
(a) I only
(b) None
(c) II only
(d) I and II
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 2.3.1, subsection "A Non-contiguous List," in the course notes.
--------------------------------------------------------------------------------
8.
Consider the following code fragment, where L is a linked list of integers.
for( it = L.begin(); it != L.end(); ++it )
*it += 10;
Execution of this fragment has the effect of
(a) adding 10 to each list element
(b) appending 10 to the list
(c) inserting a new element 10 after each list element
(d) stepping through the lists in increments of 10
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.2.3 of the course notes.
--------------------------------------------------------------------------------
9.
Which of the following operations is (are) typically more efficient in a linked list than in a vector?
Removal of the first element
Random element access
(a) I and II
(b) None
(c) II only
(d) I only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 2.3.1, subsection "A Non-Contiguous List," in the course notes.
--------------------------------------------------------------------------------
10.
To access an element in a singly linked list, a program must
(a) allocate memory for temporary nodes
(b) traverse all nodes in the list prior to that element
(c) add the element's index to the memory address of the first element in the list
(d) compute a hash value for the element
Correct answer is (b)
Your score on this question is: 10.00
Feedback:
See section 2.3.1 in the course notes.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 80.00
? Copyright 2004 iCarnegie, Inc. All rights reserved.
Your performance was as follows:
You took 6 minutes on this assessment from Mon Dec 11 15:41:23 UTC+0800 2006 to Mon Dec 11 15:47:13 UTC+0800 2006.
Total score: 80.00
1.
Consider the following C++ program segment, which uses the STL.
stack<int,vector<int> > S;
Execution of the statement results in creation of which of the following?
(a) A vector of integer stacks
(b) A stack of integers
(c) A vector of integers
(d) A stack of integer vectors
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 2.4.2 of the course notes.
--------------------------------------------------------------------------------
2.
Which of the following is a method (are methods) available in the class queue in the C++ Standard Template Library?
push
pop
enqueue
(a) III only
(b) None
(c) I and II only
(d) I, II, and III
Correct answer is (c)
Your score on this question is: 10.00
Feedback:
See Chapter 7, page 249, in the course textbook.
--------------------------------------------------------------------------------
3.
The queue adapter interface in the C++ Standard Template Library contains which of the following member functions?
push
pop_back
(a) I only
(b) None
(c) II only
(d) I and II
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.4.2 in the course notes.
--------------------------------------------------------------------------------
4.
Which of the following statements is (are) true about stacks?
Elements are inserted and deleted in last-in-first-out order.
Stacks can be implemented using linked lists.
Stacks can be implemented using arrays.
(a) I, II, and III
(b) I and II only
(c) I and III only
(d) II and III only
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.4.1 of the course notes.
--------------------------------------------------------------------------------
5.
Which of the following data structures uses a "Last-in, First-out" policy for element insertion and removal?
(a) Tree
(b) Queue
(c) Hash table
(d) Stack
Correct answer is (d)
Your score on this question is: 10.00
Feedback:
See section 2.5.1, subsection "Stacks Introduced," in the course notes.
--------------------------------------------------------------------------------
6.
Which of the following is not a basic operation that can be performed on a queue?
(a) Inserting an item into the second position of the queue
(b) Inserting an item at the back of the queue
(c) Removing an item from the front of the queue
(d) Accessing an item from the front of the queue
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See Chapter 7, page 236, in the course textbook.
--------------------------------------------------------------------------------
7.
Execution of the code fragment
list<int> A(10);
does which of the following?
(a) Creates 10 linked lists of ints, all initially empty.
(b) Creates a linked list of 10 ints, with each element initially 0.
(c) Creates a linked list of 10 ints, with each element initially containing random values.
(d) Creates an empty linked list of ints, but reserves memory for 10 entries
Correct answer is (b)
Your score on this question is: 10.00
Feedback:
See section 2.2.3 of the course notes.
--------------------------------------------------------------------------------
8.
Typical implementations for which of the following STL containers store elements contiguously in memory?
vector
list
(a) None
(b) II only
(c) I only
(d) I and II
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 2.3.1, subsection "A Non-contiguous List," in the course notes.
--------------------------------------------------------------------------------
9.
Which of the following pointers is (are) stored by nodes in a doubly-linked list?
A pointer to the next node
A pointer to the previous node
(a) I and II
(b) II only
(c) I only
(d) None
Correct answer is (a)
Your score on this question is: 10.00
Feedback:
See section 2.3.1, subsection "Linking Elements Together," in the course notes.
--------------------------------------------------------------------------------
10.
Which of the following statements is (are) true about the locations of a linked list's nodes in memory?
Nodes must appear at a fixed distance from one another in memory.
The order of elements in a list must match the order of the list's nodes in memory.
(a) I only
(b) I and II
(c) II only
(d) None
Correct answer is (d)
Your score on this question is: 10.00
Feedback:
See section 2.3.1, subsection "A Non-Contiguous List," in the course notes.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 80.00
? Copyright 2004 iCarnegie, Inc. All rights reserved.
View Assessment Result: Multiple-Choice Quiz 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -