Deck 17: The Standard Template Library

Full screen (f)
exit full mode
Question
An associative container stores data in a nonsequential way so it is slower to locate elements than a sequence container.
Use Space or
up arrow
down arrow
to flip the card.
Question
An iterator is a function that is used to access items in an array.
Question
An associative container uses __________ to access elements rapidly.

A) data
B) functions
C) keys
D) complex sort algorithms
E) None of these
Question
A sequence container organizes data in a sequential fashion, similar to an array.
Question
Because the array class's [] operator will perform bounds checking, it is acceptable to use a subscript that is out of bounds.
Question
A function object is an object that acts like a function and is also known as a functor.
Question
The three sequence container objects provided by the STL are

A) set, multiset, and map
B) vector, deque, and list
C) map, list, and array
D) multimap, map, and multilist
E) None of these
Question
A vector is an associative container that works like an array but is dynamic in size.
Question
A set is an associative container containing elements that must all be unique.
Question
A(n) __________ is a class that stores data and organizes it in some fashion.

A) iterator
B) container
C) template
D) box
E) None of these
Question
The Standard Template Library (STL) contains templates for useful algorithms and data structures.
Question
A(n) __________ is like a pointer. It is used to access the individual data elements in a container.

A) element access operator
B) subscript indicator
C) global data finder
D) iterator
E) None of these
Question
In a mapping, each element must have one of the following two parts:
either a key or a value.
Question
The STL provides many algorithms which are implemented as function templates and are included in the header file.
Question
You can use the name of a function to get that function's address in memory and, therefore, get a function pointer to point to the function's executable code.
Question
Two types of container classes in the STL are

A) sequence and associative
B) box and cylinder
C) array and struct
D) constant and literal
E) None of these
Question
A mutable iterator gives you read/write access to the element to which the iterator points.
Question
The most important data structures in the STL are __________

A) arrays and structures
B) lists and groups
C) containers and iterators
D) templates and prototypes
E) None of these
Question
When you declare an iterator to work with a container, the compiler automatically chooses the right type.
Question
To improve runtime performance, C++11 introduced a new family of member functions that use the emplacement technique to insert new elements.
Question
An iterator of the iterator type that gives you read/write access to the element to which the iterator points is known as a(n)

A) immutable iterator
B) mutable iterator
C) auto iterator
D) range iterator
E) None of these
Question
Select all that apply. Which of the following are member functions of the vector class that use emplacement?

A) insert()
B) push_back()
C) emplace()
D) emplace_back()
E) None of these
Question
Which of the following types of iterators is(are) not supported by the vector class?

A) const_iterator
B) reverse_iterator
C) const_reverse_iterator
D) All of these are supported by the vector class
E) None of these are supported by the vector class
Question
The algorithms provided by the STL are implemented as __________ and perform various operations on elements of containers.

A) virtual functions
B) function templates
C) global variables
D) private data members
E) None of these
Question
The difference between the unordered_multimap class and the multimap class is that

A) the unordered_multimap class uses the binary tree data structure for internal storage while the multimap class uses a hash table
B) the multimap class uses the binary tree data structure for internal storage while the unordered_multimap class uses a hash table
C) the keys in the unordered_multimap class are sorted while the keys in the multimap class are in no particular order
D) None of these
Question
To retrieve a value from a map, you call the __________ member function and pass the __________ that is associated with the desired value.

A) at(), key
B) at(), value
C) key(), key
D) pair(), key
E) None of these
Question
Select all that apply. Which of the following statement(s) is(are) true about the set container?

A) It is an associative container.
B) All the elements in a set must be unique.
C) A set container is virtually the same as a size container.
D) The elements in a set are automatically sorted in ascending order.
Question
Because a vector container uses a dynamically allocated array to hold its elements, it is common for the vector class to allocate

A) less memory than it needs
B) more memory than it needs
C) a separate memory location for copies of new elements
D) None of these
Question
When an element is stored in a map, it is stored as an object of the __________ type.

A) map
B) key
C) pair
D) key_value
E) None of these
Question
To use the binary_search() algorithm you need to include ___________

A) two arguments which are iterators
B) two header files, algorithm.h and search.h
C) three arguments which are two iterators and a value
D) one argument which is a value
E) None of these
Question
Select all that apply. Which of the following are types of iterators?

A) input and output
B) forward and bidirectional
C) random-access
D) None of these
Question
To use the map class, you must include

A) #include
B) #include
C) #include
D) #include
E) None of these
Question
Select all that apply. Which of the following statement(s) is(are) not true?

A) A map is an associative container.
B) Each element in a map has two parts.
C) Map elements are usually referred to as key-value pairs.
D) The key value in a map is used to locate a value.
E) The value element in a map is used to locate the key.
Question
The vector class has a ________ member function which can be used to request an increase in the vector's capacity and a __________ member function to decrease a vector's capacity.

A) size(), max_size()
B) capacity(), reserve()
C) max_size(), shrink()
D) reserve(), shrink_to_fit()
E) None of these
Question
Which of the following defines an array object that holds three strings?

A) array items = {blue, green, yellow}
B) array items = {'blue', 'green', 'yellow',}
C) array items = {"blue", "green", "yellow"}
D) array<4> string items {"blue", "green", "yellow"}
E) None of these
Question
A technique introduced by C++11 to improve runtime performance is known as

A) insertion
B) emplacement
C) push
D) multimove
E) None of these
Question
Select all that apply. An object of a class that overloads the function call operator is a(n)

A) call operator
B) function object
C) functor
D) overloader object
Question
A sequence container that is dynamic in size is a(n)

A) array
B) map
C) vector
D) multimap
E) None of these
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/38
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 17: The Standard Template Library
1
An associative container stores data in a nonsequential way so it is slower to locate elements than a sequence container.
False
2
An iterator is a function that is used to access items in an array.
False
3
An associative container uses __________ to access elements rapidly.

A) data
B) functions
C) keys
D) complex sort algorithms
E) None of these
C
4
A sequence container organizes data in a sequential fashion, similar to an array.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
5
Because the array class's [] operator will perform bounds checking, it is acceptable to use a subscript that is out of bounds.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
6
A function object is an object that acts like a function and is also known as a functor.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
7
The three sequence container objects provided by the STL are

A) set, multiset, and map
B) vector, deque, and list
C) map, list, and array
D) multimap, map, and multilist
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
8
A vector is an associative container that works like an array but is dynamic in size.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
9
A set is an associative container containing elements that must all be unique.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
10
A(n) __________ is a class that stores data and organizes it in some fashion.

A) iterator
B) container
C) template
D) box
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
11
The Standard Template Library (STL) contains templates for useful algorithms and data structures.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
12
A(n) __________ is like a pointer. It is used to access the individual data elements in a container.

A) element access operator
B) subscript indicator
C) global data finder
D) iterator
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
13
In a mapping, each element must have one of the following two parts:
either a key or a value.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
14
The STL provides many algorithms which are implemented as function templates and are included in the header file.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
15
You can use the name of a function to get that function's address in memory and, therefore, get a function pointer to point to the function's executable code.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
16
Two types of container classes in the STL are

A) sequence and associative
B) box and cylinder
C) array and struct
D) constant and literal
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
17
A mutable iterator gives you read/write access to the element to which the iterator points.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
18
The most important data structures in the STL are __________

A) arrays and structures
B) lists and groups
C) containers and iterators
D) templates and prototypes
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
19
When you declare an iterator to work with a container, the compiler automatically chooses the right type.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
20
To improve runtime performance, C++11 introduced a new family of member functions that use the emplacement technique to insert new elements.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
21
An iterator of the iterator type that gives you read/write access to the element to which the iterator points is known as a(n)

A) immutable iterator
B) mutable iterator
C) auto iterator
D) range iterator
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
22
Select all that apply. Which of the following are member functions of the vector class that use emplacement?

A) insert()
B) push_back()
C) emplace()
D) emplace_back()
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following types of iterators is(are) not supported by the vector class?

A) const_iterator
B) reverse_iterator
C) const_reverse_iterator
D) All of these are supported by the vector class
E) None of these are supported by the vector class
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
24
The algorithms provided by the STL are implemented as __________ and perform various operations on elements of containers.

A) virtual functions
B) function templates
C) global variables
D) private data members
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
25
The difference between the unordered_multimap class and the multimap class is that

A) the unordered_multimap class uses the binary tree data structure for internal storage while the multimap class uses a hash table
B) the multimap class uses the binary tree data structure for internal storage while the unordered_multimap class uses a hash table
C) the keys in the unordered_multimap class are sorted while the keys in the multimap class are in no particular order
D) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
26
To retrieve a value from a map, you call the __________ member function and pass the __________ that is associated with the desired value.

A) at(), key
B) at(), value
C) key(), key
D) pair(), key
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
27
Select all that apply. Which of the following statement(s) is(are) true about the set container?

A) It is an associative container.
B) All the elements in a set must be unique.
C) A set container is virtually the same as a size container.
D) The elements in a set are automatically sorted in ascending order.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
28
Because a vector container uses a dynamically allocated array to hold its elements, it is common for the vector class to allocate

A) less memory than it needs
B) more memory than it needs
C) a separate memory location for copies of new elements
D) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
29
When an element is stored in a map, it is stored as an object of the __________ type.

A) map
B) key
C) pair
D) key_value
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
30
To use the binary_search() algorithm you need to include ___________

A) two arguments which are iterators
B) two header files, algorithm.h and search.h
C) three arguments which are two iterators and a value
D) one argument which is a value
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
31
Select all that apply. Which of the following are types of iterators?

A) input and output
B) forward and bidirectional
C) random-access
D) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
32
To use the map class, you must include

A) #include
B) #include
C) #include
D) #include
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
33
Select all that apply. Which of the following statement(s) is(are) not true?

A) A map is an associative container.
B) Each element in a map has two parts.
C) Map elements are usually referred to as key-value pairs.
D) The key value in a map is used to locate a value.
E) The value element in a map is used to locate the key.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
34
The vector class has a ________ member function which can be used to request an increase in the vector's capacity and a __________ member function to decrease a vector's capacity.

A) size(), max_size()
B) capacity(), reserve()
C) max_size(), shrink()
D) reserve(), shrink_to_fit()
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following defines an array object that holds three strings?

A) array items = {blue, green, yellow}
B) array items = {'blue', 'green', 'yellow',}
C) array items = {"blue", "green", "yellow"}
D) array<4> string items {"blue", "green", "yellow"}
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
36
A technique introduced by C++11 to improve runtime performance is known as

A) insertion
B) emplacement
C) push
D) multimove
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
37
Select all that apply. An object of a class that overloads the function call operator is a(n)

A) call operator
B) function object
C) functor
D) overloader object
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
38
A sequence container that is dynamic in size is a(n)

A) array
B) map
C) vector
D) multimap
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 38 flashcards in this deck.