⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiple-choice quiz 5.txt

📁 icarnegie ssd5 choice5
💻 TXT
📖 第 1 页 / 共 3 页
字号:

 Your performance was as follows:  

 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 stack of integer vectors
 (b) A stack of integers
 (c) A vector of integer stacks
 (d) A vector of integers  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.4.2 of the course notes.  
 

--------------------------------------------------------------------------------

 2. 
 The queue adapter interface in the C++ Standard Template Library contains which of the following member functions?

push 
pop_back 
 
 

  (a) I only
 (b) II only
 (c) None
 (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.
 
 

--------------------------------------------------------------------------------

 3. 
 In the C++ Standard Template Library (STL), the class queue is _____ that uses _____ for storage. 
 
 

  (a) an adapter, a sequence container
 (b) a sequence container, a C-style array
 (c) a sequence container, an adapter class
 (d) an adapter, a C-style array  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   
See Chapter 7, page 249, in the course textbook. 
 
 

--------------------------------------------------------------------------------

 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) II and III only
 (b) I and II only
 (c) I, II, and III
 (d) I and III only  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.4.1 of the course notes.  
 

--------------------------------------------------------------------------------

 5. 
 Which of the following is (are) typically managed using a stack? 

Implementation of function calls in a procedural programming language 
Evaluating arithmetic expressions, taking precedence rules into account 
Handling jobs sent to a printer, and ensuring that the first jobs to be submitted are printed first
 
 

  (a) II only
 (b) I and II only
 (c) I, II, and III
 (d) I and III only  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   
See Chapter 7, pages 235–236, in the course textbook. 
 
 

--------------------------------------------------------------------------------

 6. 
 Which of the following linear data structures use a first-in, first-out element insertion and removal policy?

Stacks 
Queues 
 
 

  (a) II only
 (b) I and II
 (c) I only
 (d) None  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   
See sections 2.4.1 and 2.5.1 in the course notes.
 
 

--------------------------------------------------------------------------------

 7. 
 In STL, nodes of a linked list can be accessed using which of the following? 

STL iterators 
Subscripts
 
 

  (a) None
 (b) I only
 (c) II only
 (d) I and II  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.2.3 of the course notes.  
 

--------------------------------------------------------------------------------

 8. 
 In the C++ standard template library (STL), which of the following is a property of const iterators for the list container?
 
 

  (a) They provide read-only access to a linked list.
 (b) They cannot be used to traverse a linked list.
 (c) Const iterators can be incremented, but never decremented.
 (d) They provide write-only access to a linked list.  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.2.3 of the course notes.  
 

--------------------------------------------------------------------------------

 9. 
 To access an element in a singly linked list, a program must 
 
 

  (a) add the element's index to the memory address of the first element in the list
 (b) traverse all nodes in the list prior to that element
 (c) compute a hash value for the element
 (d) allocate memory for temporary nodes  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.3.1 in the course notes. 
 
 

--------------------------------------------------------------------------------

 10. 
 Which of the following is (are) typically true about linked lists?

Objects in a linked list are stored contiguously in memory. 
All elements in a list are copied to new locations in memory upon frontal insertions to the list. 
 
 

  (a) I only
 (b) None
 (c) II only
 (d) I and II  

 Correct answer is  (b)  

 Your score on this question is: 0.00  

 Feedback: 
   
See section 2.3.1 in the course notes.
 
 

--------------------------------------------------------------------------------

 Go to top of assessmely, backward only  

 Correct answer is  (b)  

 Your score on this question is: 0.00  
1. 
 Consider the following C++ program segment, which uses the STL. 

stack<int> X;
X.push(2);
X.push(14);
X.pop();
X.push(37);
X.push(40);
X.pop();
cout << X.top();
What is the output when this program segment is executed? 
 
 

  (a) 40
 (b) 37
 (c) 2
 (d) 14  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.4.2 of the course notes.
   (b)  
 



--------------------------------------------------------------------------------

 2. 
 In order to use the adapter queue from the C++ Standard Template Library, which of the following preprocessor directives is (are) typically required?

#include <queue> 
#include <deque> 
 
 

  (a) None
 (b) I only
 (c) I and II
 (d) II only  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.4.2 in the course notes.


   (b)  
 

--------------------------------------------------------------------------------

 3. 
 In the C++ Standard Template Library (STL), the class queue is _____ that uses _____ for storage. 
 
 

  (a) a sequence container, an adapter class
 (b) a sequence container, a C-style array
 (c) an adapter, a C-style array
 (d) an adapter, a sequence container  

 Correct answer is  (d)  

 Your score on this question is: 10.00  

 Feedback: 
   
See Chapter 7, page 249, in the course textbook. 


   (d)  
 

--------------------------------------------------------------------------------

 4. 
 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. 


   (d)  
 

--------------------------------------------------------------------------------

 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) I and III only
 (c) I and II 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.
   (a)  
 

--------------------------------------------------------------------------------

 6. 
 Consider the following sequence of operations applied to an empty queue:

Insert element with value 3 
Insert element with value 8
Remove element
Insert element with value 1
Remove element
Insert element with value 7

The next element removed from this queue will have which of the following values?
 
 

  (a) 8
 (b) 3
 (c) 1
 (d) 7  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.4.1 in the course notes.


   (c)  
 

--------------------------------------------------------------------------------

 7. 
 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) appending 10 to the list
 (b) stepping through the lists in increments of 10
 (c) inserting a new element 10 after each list element
 (d) adding 10 to each list element  

 Correct answer is  (d)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.2.3 of the course notes.
   (d)  
 

--------------------------------------------------------------------------------

 8. 
 One thing that the STL vector and the STL list have in common is that both are  
 

  (a) sequential containers
 (b) based on arrays of elements
 (c) inherited from the superclass Container
 (d) random access containers  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.2.2 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 9. 
 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) II only
 (b) I only
 (c) None
 (d) I and II  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.3.1, subsection "A Non-Contiguous List," in the course notes.


   (c)  
 

--------------------------------------------------------------------------------

 10. 
 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) None
 (b) I and II
 (c) I only
 (d) II only  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.3.1, subsection "A Non-Contiguous List," in the course notes. 


   (c)  
8. 
 Consider the execution of the following.

    list<int>  A(10,20);

Which of the following accurately describes what is created?
 
 

  (a) A linked list of size 10, each containing 10 arrays of ints of size 20
 (b) a linked list of 10 linked lists, each containing 20 ints
 (c) An array of size 20 of linked list, each containing 20 ints
 (d) A linked list of 10 ints, with each element initially 20  

 Correct answer is  (d)  

 Your score on this question is: 10.00 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -