Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

In deck we can add and remove elements from both sides, but in vectors only from the back.

Читайте также:
  1. An Electrical Circuit and Its Elements
  2. Basic Elements and Assumptions of Game Theory
  3. Biogenetic classification of elements
  4. Content of some elements in plants, animal and human organisms, mg/kg
  5. Create 4 new elements for a 2D platform game, then create a small level where you use these elements and all the other elements that the game already has.
  6. Design Elements
  7. Design elements

In vector we can add and delete elements only from the end of the container.

 

9. Visualization of functions push_back() and pop_back()

10. Difference of deck and vector

In deck we can add and remove elements from both sides, but in vectors only from the back.

 

11. Push_front() and pop_front() functions of deck container

 

12. For an STL iterator it, execution of the statement

 

 

13. • it--; does which of the following?

 

(c) Steps the iterator backwards to the previous item.

.

30. Access to ranges of elements in an STL container is typically handled by

(a) iterators

 

31. For an STL iterator it, execution of the statement

++it; does which of the following?

(c) Advances the iterator to the next item.

1.   Access to ranges of elements in an STL container is typically handled by  

 

  (a) iterators
   

 

  2.   Execution of which of the following statements sets an STL iterator it so that it points to the first element of a container A?  

 

  (d) it = A.begin();

 

  3.   The main abstractions of the Standard Template Library include which of the following? I. Iterators II. Exception handlers III. Algorithms  

 

  (d) I and III only

 

  4.   A typical implementation of a deque in the C++ STL minimizes the need to copy elements upon the frontal insertion of new items by  

 

  (c) reserving memory at the front of the deque's stored elements

 

  5.   In the C++ Standard Template Library, vectors and deques differ in their interfaces for handling which of the following operations? I. Insertion of an element at the front of the container II. Insertion of an element at the end of the container III. Removal of an element from the front of the container  

 

  (a) I and III only

 

  6.   In STL vectors, _____ refers to the maximum number of items that can be stored without resizing, and _____ refers to the number of items stored.  

 

  (b) capacity, size

 

  7.   Consider the following declaration that makes use of a user-defined class Thing. vector<Thing> A(10); In order that it compile, the class Thing must have which of the following?  

 

  (a) a default constructor

 

  8.   If A is an STL vector, then the effect of executing the statement A[i] = x; is to  

 

  (a) write x to position i of the vector, without bounds checking

 

  9.   Consider the following C++ program segment, assuming that string is a class. string str1("Hello, World"); str1[5] = 'Z'; The overloaded operator[] function invoked in the above program segment should have which of the following return types?  

 

  (a) char &

 

  10.   Which of the following statements is (are) true regarding C-style strings? I. They are terminated by the null character. II. Storing a five-character string requires at least seven characters.  

 

  (b) I only  
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?  
           

 

  (d) 37

 

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

 

  (c) I only

 

  3.   An STL adapter provides  

 

  (d) a new programming interface for an existing STL container

 

  4.   Which of the following operations typically removes an item from a stack?  

 

  (d) pop

 

  5.   Which of the following is (are) typically managed using a stack? I. Implementation of function calls in a procedural programming language II. Evaluating arithmetic expressions, taking precedence rules into account III. Handling jobs sent to a printer, and ensuring that the first jobs to be submitted are printed first  

 

  (c) I and II only  

 

  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

 

  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  

 

  (b) inserting a new element 10 after each list element

 

  8.   Typical implementations for which of the following STL containers store elements contiguously in memory? I. vector II. list  

 

  (a) I only    

 

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

 

  (a) traverse all nodes in the list prior to that element    

 

  10.   A singly linked list is a linked list in which  

 

    (b) each node contains a pointer to only one other node
1.   How many calls to itself is a recursive function allowed to make?  
           

 

  (d) Any number

 

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

 

  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  

 

  (c) a power of 2

 

  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  

 

  (b) non-negative  

 

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

 

  (d) 2

 

  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?  

 

  (c) For x = 0 only

 

  7.   Which of the following is (are) true of the minimax strategy for deciding the optimal move in a two-person game? I. It assumes that a human player will eventually make a mistake by playing a move that is not optimal. II. It is commonly used with a backtracking algorithm.  

 

  (a) II only

 

  8.   A backtracking algorithm is one that  

 

  (a) uses recursion to test all possible solutions for a problem

 

  9.   Typical divide and conquer algorithms use _____ to divide a problem into smaller sub-problems. The _____ typically solve(s) these sub-problems directly.  

 

  (d) recursive function calls, base case of the recursion

 

  10.   What is the runtime overhead of a divide-and-conquer algorithm that recursively processes two equal halves of a problem that each have an overhead of O(n)?  

 

  (d) O(n log n)    
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?  
           

 

  (c) Container A is sorted using the Boolean valued function f for comparisons.

 

  2.   Which of the following statements is true of the selection-sort algorithm? I. It is a divide-and-conquer algorithm typically implemented using recursion. II. An implementation of the algorithm typically requires the use of a hash table.  

 

  (c) None  

 

  3.   Which of the following search algorithms can be applied to unsorted data? I. Linear search II. Binary search  

 

  (b) I only

 

  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? I. Linear search II. Binary search  

 

  (b) I only

 

  5.   What is the purpose of using memoizing?  

 

  (a) To improve the memory requirements of hash tables (b) To speed up access in a hash table (c) To store return values of functions, in order to avoid recomputation (d) To eliminate recursion in computing function values

 

  6.   Which of the following indicates the primary difficulty with hashing in general?  

 

  (b) Collisions will occur..

 


Дата добавления: 2015-11-16; просмотров: 51 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Reuse empty spaces.| Year 5 Why I like country Music; Questions on the TEXT, to P 2

mybiblioteka.su - 2015-2024 год. (0.017 сек.)