Deck 5: Sequential Containers

Full screen (f)
exit full mode
Question
A template class is a class that stores and processes a collection of information.
Use Space or
up arrow
down arrow
to flip the card.
Question
If you remove an element from a vector object, the size automatically decreases.
Question
The for loop below is designed to populate an int type vector named my_vector with the first ten odd positive integers. Using the vector class at() function, complete the for loop.
for (int index = 0; index ++; index < 10)
__________
Question
When implementing a(n) __________ class, all of the code must be in the header or in a file included by the header.

A) derived
B) base
C) public
D) template
Question
Which of the following headers changes the subscript operator defined below so that it returns a non-modifiable reference?
<strong>Which of the following headers changes the subscript operator defined below so that it returns a non-modifiable reference?  </strong> A) const Item_Type& operator[](size_t index) B) const Item_Type& operator[](size_t index) const C) Item_Type& operator[](size_t index) const D) static Item_Type& operator[](size_t index) const <div style=padding-top: 35px>

A) const Item_Type& operator[](size_t index)
B) const Item_Type& operator[](size_t index) const
C) Item_Type& operator[](size_t index) const
D) static Item_Type& operator[](size_t index) const
Question
To insert an item into the middle of the array, the values that are at the __________ point and beyond must be shifted over to make room.

A) insertion
B) starting
C) mid
D) end
Question
Most of the user-defined operational expense in the KW::vector class reserve function is attributable to the for loop excerpted below.
<strong>Most of the user-defined operational expense in the KW::vector class reserve function is attributable to the for loop excerpted below.   Using order of growth techniques against this code fragment, we can estimate that each reallocation of reserve () is __________.</strong> A) O(1) B) O(n log<sub>2</sub>n) C) O(n) D) O(n<sup>2</sup>) <div style=padding-top: 35px>
Using order of growth techniques against this code fragment, we can estimate that each reallocation of reserve () is __________.

A) O(1)
B) O(n log2n)
C) O(n)
D) O(n2)
Question
Even if we have to reallocate in a call to KW::vector class insert (), the cost of the operation would still be O(__________).
Question
The purpose of the copy constructor is to create a shallow copy of an object.
Question
For class types, assignment is done by what is appropriately known as the __________ operator.
Question
The variable called "this" is a(n) __________ to the object to which a member function is applied.
Question
A(n) __________ list provides the ability to add or remove items anywhere in the list in constant (O(1)) time.
Question
A(n) __________ is a pointer to a node.

A) struct
B) node
C) link
D) item
Question
Provide a critical line of code that will enable the while loop below to terminate.
Provide a critical line of code that will enable the while loop below to terminate.  <div style=padding-top: 35px>
Question
You can create a __________ liked list by linking the last node to the first node (and the first node to the last one).

A) single
B) circular
C) double
D) reverse
Question
A(n) __________ is a moving place marker that can be advanced forward (using operator++) or backward (using operator--).
Question
In the context of iterators, a(n) __________ represents a common interface that a generic class must meet.
Question
What value is output after the final line in the following code segment executes?
<strong>What value is output after the final line in the following code segment executes?  </strong> A) -842150451 B) 0 C) 55 D) 89 <div style=padding-top: 35px>

A) -842150451
B) 0
C) 55
D) 89
Question
Which of the following conditions will enable this KW::list function to perform its task?
<strong>Which of the following conditions will enable this KW::list function to perform its task?  </strong> A) tail->next != NULL B) tail != NULL C) tail == NULL D) tail->next == NULL <div style=padding-top: 35px>

A) tail->next != NULL
B) tail != NULL
C) tail == NULL
D) tail->next == NULL
Question
Which line will properly complete the definition for KW::iterator class postfix increment operator?
Iterator operator++(int) {
Iterator return_value = *this;
__________
Return return_value;
}

A) this++
B) ++this
C) --(*this)
D) ++(*this)
Question
Because a list and a vector have several member functions in common, they may be used polymorphically.
Question
The associative containers are designed for fast retrieval of data based on a unique value stored in each item, called its __________.
Question
Provide the code that completes the definition of the STL template find function below.
Provide the code that completes the definition of the STL template find function below.  <div style=padding-top: 35px>
Question
The template functions, or __________perform fairly standard operations on containers, such as applying the same function to each element (for_each), copying values from one container to another (copy), searching a container for a target value (find, find_if), or sorting a container (sort).

A) algorithms
B) procedures
C) methods
D) routines
Question
The function call operator cannot be overloaded by a class.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Sequential Containers
1
A template class is a class that stores and processes a collection of information.
True
2
If you remove an element from a vector object, the size automatically decreases.
True
3
The for loop below is designed to populate an int type vector named my_vector with the first ten odd positive integers. Using the vector class at() function, complete the for loop.
for (int index = 0; index ++; index < 10)
__________
my_vector.at(index) = 2 * index + 1;
4
When implementing a(n) __________ class, all of the code must be in the header or in a file included by the header.

A) derived
B) base
C) public
D) template
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following headers changes the subscript operator defined below so that it returns a non-modifiable reference?
<strong>Which of the following headers changes the subscript operator defined below so that it returns a non-modifiable reference?  </strong> A) const Item_Type& operator[](size_t index) B) const Item_Type& operator[](size_t index) const C) Item_Type& operator[](size_t index) const D) static Item_Type& operator[](size_t index) const

A) const Item_Type& operator[](size_t index)
B) const Item_Type& operator[](size_t index) const
C) Item_Type& operator[](size_t index) const
D) static Item_Type& operator[](size_t index) const
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
To insert an item into the middle of the array, the values that are at the __________ point and beyond must be shifted over to make room.

A) insertion
B) starting
C) mid
D) end
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
Most of the user-defined operational expense in the KW::vector class reserve function is attributable to the for loop excerpted below.
<strong>Most of the user-defined operational expense in the KW::vector class reserve function is attributable to the for loop excerpted below.   Using order of growth techniques against this code fragment, we can estimate that each reallocation of reserve () is __________.</strong> A) O(1) B) O(n log<sub>2</sub>n) C) O(n) D) O(n<sup>2</sup>)
Using order of growth techniques against this code fragment, we can estimate that each reallocation of reserve () is __________.

A) O(1)
B) O(n log2n)
C) O(n)
D) O(n2)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
Even if we have to reallocate in a call to KW::vector class insert (), the cost of the operation would still be O(__________).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
The purpose of the copy constructor is to create a shallow copy of an object.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
For class types, assignment is done by what is appropriately known as the __________ operator.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
The variable called "this" is a(n) __________ to the object to which a member function is applied.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
A(n) __________ list provides the ability to add or remove items anywhere in the list in constant (O(1)) time.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
A(n) __________ is a pointer to a node.

A) struct
B) node
C) link
D) item
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
Provide a critical line of code that will enable the while loop below to terminate.
Provide a critical line of code that will enable the while loop below to terminate.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
You can create a __________ liked list by linking the last node to the first node (and the first node to the last one).

A) single
B) circular
C) double
D) reverse
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
A(n) __________ is a moving place marker that can be advanced forward (using operator++) or backward (using operator--).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
In the context of iterators, a(n) __________ represents a common interface that a generic class must meet.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
What value is output after the final line in the following code segment executes?
<strong>What value is output after the final line in the following code segment executes?  </strong> A) -842150451 B) 0 C) 55 D) 89

A) -842150451
B) 0
C) 55
D) 89
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following conditions will enable this KW::list function to perform its task?
<strong>Which of the following conditions will enable this KW::list function to perform its task?  </strong> A) tail->next != NULL B) tail != NULL C) tail == NULL D) tail->next == NULL

A) tail->next != NULL
B) tail != NULL
C) tail == NULL
D) tail->next == NULL
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
Which line will properly complete the definition for KW::iterator class postfix increment operator?
Iterator operator++(int) {
Iterator return_value = *this;
__________
Return return_value;
}

A) this++
B) ++this
C) --(*this)
D) ++(*this)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
Because a list and a vector have several member functions in common, they may be used polymorphically.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
The associative containers are designed for fast retrieval of data based on a unique value stored in each item, called its __________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
Provide the code that completes the definition of the STL template find function below.
Provide the code that completes the definition of the STL template find function below.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
The template functions, or __________perform fairly standard operations on containers, such as applying the same function to each element (for_each), copying values from one container to another (copy), searching a container for a target value (find, find_if), or sorting a container (sort).

A) algorithms
B) procedures
C) methods
D) routines
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
The function call operator cannot be overloaded by a class.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.