Final C++ - Chapter 15: Standard Library Containers and Iterators

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Iterators are similar to pointers because of the: a. * and ++ operators. b. -> operator. c. begin and end functions. d. & operator.

a. * and ++ operators.

Which of the following statements is FALSE? a. C++14's global rbegin, rend, crbegin and crend functions are for iterating through a built-in array or a container from back to front. b. Functions rbegin and rend return iterators that can be used to modify data, and rcbegin and rcend return const iterators that cannot be used to modify data. c. Functions begin and end and their C++14 const and reverse versions may also receive container objects as arguments—each function calls the corresponding member function in its container argument. d. When iterating using iterators, it's common for the loop-continuation condition to test whether the iterator has reached the end of the built-in array or the container. This technique is used by many Standard Library algorithms.

Functions rbegin and rend return iterators that can be used to modify data, and rcbegin and rcend return const iterators that cannot be used to modify data.

If pairs is a map containing int keys and double associated values, the expression pairs[5] = 10: a. Associates the value 10.0 to the key 5 in pairs. b. Associates the value 5.0 to the key 10 in pairs. c. Associates the value associated with key 10 to key 5 in pairs. d. Associates the value associated with key 5 to key 10 in pairs

a. Associates the value 10.0 to the key 5 in pairs.

Which category of iterators combines the capabilities of input and output iterators into one iterator? a. Forward iterators. b. Bidirectional iterators. c. Random access iterators. d. Input/output iterators.

a. Forward iterators

Which of the following is the correct hierarchy of iterator categories (weakest at the left)? a. Input/output, forward, bidirectional, random access. b. Random access, forward, bidirectional, input/output. c. Bidirectional, forward, random access, input/output. d. Input/output, bidirectional, forward, random access.

a. Input/output, forward, bidirectional, random access.

Which of the following is not an Standard Library CONTAINER TYPE? a. Second-class containers. b. Sequence containers. c. Associative containers. d. Container adapters.

a. Second-class containers.

Assuming that bitset b1 contains the bits [0 1 1 0] and bitset b2 contains the bits [1 1 1 1], which of the following expressions returns true? a. b1.any() b. b1 == b2 c. b1.test(3) d. b2.none()

a. b1.any()

Which of the following is a NOT a member function of queue? a. enqueue b. pop c. empty d. size

a. enqueue

Part of the functionality of member function _________ can be performed by member function lower_bound. a. equal_range b. find c. count d. insert

a. equal_range

Which of the following applications would a deque not be well suited for? a. Applications that require frequent insertions and deletions at the front of a container. b. Applications that require frequent insertions and deletions in the middle of a container. c. Applications that require frequent insertions and deletions at the back of a container. d. Applications that require frequent insertions and deletions at the front and at the back of a container.

b. Applications that require frequent insertions and deletions in the middle of a container.

Which of the following statements is TRUE of a priority_queue? a. It does not allow insertions in sorted order. b. Each of its common operations is implemented as an inline function. c. A bucket sort is usually associated with it. d. It must be implemented as a deque.

b. Each of its common operations is implemented as an inline function.

The erase member function of class vector cannot: a. Specify an element to be removed from the vector. b. Specify a value to be removed from the vector. c. Specify a range of elements to be removed from the vector. d. Be called by member function clear.

b. Specify a value to be removed from the vector

Which of the following is not a sequence container provided by the Standard Library? a. vector b. array c. list d. deque

b. array

Which of the following is not a member function of all sequence containers? a. front b. middle c. back d. pop_back

b. middle

As of C++11, you can ask a vector or deque to return unneeded memory to the system by calling member function shrink_to_fit. This requests that the container reduce its capacity to the number of elements in the container. According to the C++ standard, implementations can ignore this request so that they can perform implementation-specific optimizations. a. minimize_memory b. shrink_to_fit c. reduce_capacity d. squeeze_to_size

b. shrink_to_fit

Which of the following bitset member functions cannot be called with an empty argument list? a. reset b. test c. size d. none

b. test

Which of the following containers is not considered a near container? a. C-like arrays b. vectors c. strings d. bitsets

b. vectors

A Standard Library algorithm cannot: a. Return an iterator. b. Take two iterators as arguments to specify a range. c. Access Standard Library members directly. d. Be used with containers that support more powerful iterators than the minimum requirements for the algorithm.

c. Access Standard Library members directly.

Unlike a vector, a deque: a. Provides efficient insertion and deletion only at its front. b. Does not provide indexed access with the subscript operator. c. Is not stored in contiguous memory. d. Cannot store as many different data types.

c. Is not stored in contiguous memory.

Which of the following is a difference between vectors and arrays? a. Access to any element using the [] operator. b. Stored in contiguous blocks of memory. c. The ability to change size dynamically. d. Efficient direct access to any element.

c. The ability to change size dynamically.

To pop an element off the top of a stack for processing: a. Use member function top. b. Use member function pop. c. Use member function top and then member function pop. d. Use member function pop and then member function top.

c. Use member function top and then member function pop.

Which bitset function could be used to create the logical not of a bitset object b? a. b.set() b. b.reset() c. b.flip() d. b.none()

c. b.flip()

As of C++14, the argument to find (and other similar functions) can be of any type, provided that there are overloaded comparison operators that can compare values of the argument's type to values of the container's key type. If there are, no temporary objects will be created. This is known as ________ lookup. a. homogenous b. intergeneous c. heterogenous d. intrageneous

c. heterogeneous

Data loss could occur if the contents of a __________ were placed into any of the other three associative container types. a. multiset. b. set. c. multimap. d. map.

c. multimap.

Which of the following is NOT a member function of all sequence containers? a. front b. back c. push_front d. push_back

c. push_front

Class deque provides: a. Efficient indexed access to its elements. b. The ability to add storage at either end of the deque. c. Efficient insertion and deletion operations at the front and back of a deque. d. All of the above.

d. All of the above.

The list sequence container does not: a. Efficiently implement insert and delete operations anywhere in the list. b. Use a doubly linked list. c. Support bidirectional iterators. d. Automatically sort inserted items.

d. Automatically sort inserted items.

Which of the following are mutating-sequence algorithms defined in the Standard Library? a. copy b. remove_if c. find d. Both (a) and (b).

d. Both (a) and (b).

The expression std::multimap<int, double, std::less<int>>::value_type(15, 2.7): a. Creates an empty multimap object. b. Creates a multimap object containing one key/value pair. c. Returns the number of times the key/value pair (15, 2.7) appears in the multimap. d. Creates a pair object in which first is 15 (type int) and second is 2.7 (type double).

d. Creates a pair object in which first is 15 (type int) and second is 2.7 (type double).

Select the FALSE statement. Container adapters: a. Do not provide the actual data structure implementation for elements to be stored. b. Have their data stored by underlying data structures. c. Can push and pop elements. d. Have limited iterator support.

d. Have limited iterator support.

The main difference between set and multiset is: a. Their interface. b. That one deals with keys only, and the other deals with key/value pairs. c. Their efficiency. d. How they handle duplicate keys.

d. How they handle duplicate keys.

The multiset associative container DOES NOT: a. Need a header file to be used. b. Use its comparator function object to determine the order of its data. c. Arrange its data in ascending order by default. d. Permit random access to its keys.

d. Permit random access to its keys.

Which of the following is not a key component of the Standard Library? a. Containers. b. Iterators. c. Algorithms. d. Pointers.

d. Pointers

If a program attempts to insert a duplicate key into a set: a. An exception is thrown. b. The set will contain multiple copies of that key. c. A compile error will occur. d. The duplicate key will be ignored.

d. The duplicate key will be ignored.


Ensembles d'études connexes

Exam 1 Study Guide for Macroeconomics

View Set

MOD 1, 2 & 3 combined!!! (combined with quiz 1-3)

View Set

Mastery Level Quiz Chapter 19: Degenerative Changes in Aging prep u

View Set

Chapter 12: Patterns of Inheritance

View Set

Vancomycin-resistant Staphylococcus Aureus (VRSA)

View Set

Business analytics ch 1, 2, 4, 8, 10

View Set

Chapter 25 Immunological or Infectious Condition

View Set