In: Computer Science
hat are the values of the elements in the vector named names_1
after the following code is executed?
vector<string> names_1 { "Mike", "Ben", "Joel",
"Anne" };
vector<string> names_2 { "Judy", "Samantha", "Kelly" };
names_1.insert(names_1.end(), "Mary");
names_1.erase(names_1.begin());
names_1.insert(names_1.begin() + 2, ++names_2.begin(),
names_2.end());
names_1.swap(names_2);
names_1.erase(++names_1.begin());
names_1.insert(names_1.begin(), ++names_2.begin(), names_2.begin()
+ 2);
a. |
Joel, Judy, Samantha |
|
b. |
Judy, Mary, Joel, Mary |
|
c. |
Joel, Anne, Judy, Samantha |
|
d. |
Joel, Judy, Kelly |
1.5 points
QUESTION 12
What are the values of the key/value pairs in the map named
products after the following code is executed?
map<string, int> products { {"hammer", 14}, {"nails",
25}, {"wrench", 8} };
products.insert_or_assign("wrench", 18);
int quantity = products["drill"];
a. |
hammer/14 nails/25 wrench/26 drill/-1 |
|
b. |
drill/0 hammer/14 nails/25 wrench/18 |
|
c. |
hammer/14 nails/25 wrench/26 drill/0 |
|
d. |
drill/-1 hammer/14 nails/25 wrench/18 |
1.5 points
QUESTION 13
To compare the data that’s stored in two structure objects, you can
a. |
use the equality operator |
|
b. |
add an operator or function to the structure that provides that functionality |
|
c. |
compare one or more of the data members of the objects |
|
d. |
all of the above |
|
e. |
b and c only |
1.5 points
QUESTION 14
Which of the following containers has pointers that link to the previous and next elements?
a. |
list |
|
b. |
map |
|
c. |
deque |
|
d. |
array |
1.5 points
QUESTION 15
The elements of a deque are stored in
a. |
non-contiguous memory |
|
b. |
a combination of contiguous and non-contiguous memory |
|
c. |
contiguous memory |
1.5 points
QUESTION 16
What are the values of the enumerators in the enumeration that
follows?
enum class Terms {
net_30_days = 30,
net_60_days,
net_90_days
};
a. |
30, 1, 2 |
|
b. |
30, 31, 32 |
|
c. |
30, 0, 1 |
|
d. |
30, 60, 90 |
1.5 points
QUESTION 17
Which type of error can cause a program to crash or yield unexpected results?
a. |
runtime |
|
b. |
user |
|
c. |
syntax |
|
d. |
logic |
1.5 points
QUESTION 18
You can use a container adapter to
a. |
Add functionality to a deque |
|
b. |
Adapt the deque to more specialized uses |
|
c. |
Create queues and stacks |
|
d. |
All of the above |
|
e. |
b and c only |
1.5 points
QUESTION 19
Which of the following statements about structures is/are true?
a. |
A structure can define data members that store the data of a structure type. |
|
b. |
A structure can define member functions that work with the data members of the structure. |
|
c. |
A structure can define operators that work with the data members of the structure. |
|
d. |
All of the above |
|
e. |
a and c only |
1.5 points
QUESTION 20
Which of the following iterators can you use to iterate forward or backward and read and write repeatedly?
a. |
bidirectional and above |
|
b. |
input and above |
|
c. |
random-access and above |
|
d. |
forward and above |
Solution 11 and 12: Not sure about them dear, cannot provide you with the wrong solutions, thanks for understanding.
Solution 13: Option A is the correct option as the equality operator alone is actually enough to compare data that's stored in two structure objects.
Solution 14: Option A is the correct option as a linked list has the pointers that can point to the forward as well as the backward node.
Solution 15: Option C is the correct option as the elements that are present within the deque are actually stored in contiguous memory locations.
Solution 16: Option C is the correct option as the other variables would be initialized from 0 and 1 when not initialized in an enumeration.
Solution 17: Option A is the correct option as the runtime errors are actually responsible for the crashing of an application and the yield of unexpected results.
Solution 18: Option B is the correct option as the container adapters can be used for adding other functionalities to the deque.
Solution 19: Option A is the correct option as the structure allows the structure members to store the data of structure type.
Solution 20: Option A is the correct option as the Bidirectional iterators can be used for iterating forward as well as backward through the data structures.
Here's the solution to your question, please provide it a 100% rating. Thanks for asking and happy learning!!