Question

In: Computer Science

hat are the values of the elements in the vector named names_1 after the following code...

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

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

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

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

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

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

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

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

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

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

Solutions

Expert Solution

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!!


Related Solutions

MATLAB Given a 20x20 matrix named G and a 20x1 vector named H, multiply the elements...
MATLAB Given a 20x20 matrix named G and a 20x1 vector named H, multiply the elements in the 14th column of G by the values in H (element-by-element multiplication, not a multiplication table).
Write a code to ask for a vector with 10 elements from the user and replace...
Write a code to ask for a vector with 10 elements from the user and replace the 1st, 3rd, 8th  to 9th  elements with the second element of the given vector. (you can insert a vector when you use input function)
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a...
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a rectangular matrix A of dimensions 4X2 (4- rows, 2-columns); Create a matrix transpose to the above matrix A. Call that matrix AT; Calculate matrix products: A*AT and AT*A. Present the results. What are the dimensions of those two product matrices; Square matrixes sometimes have an inverse matrix. Try calculating inverse matrices (or matrixes, if you prefer) of above matrices (matrixes) A*AT and AT*A; Extend...
c++ code Reverse the order of elements in a vector of integers using two functions: (a)...
c++ code Reverse the order of elements in a vector of integers using two functions: (a) The first function takes the input vector a and return a vector b with the input data but in the reverse order, e.g. input: 1, 2, 3 and output 3, 2, 1. (b) The second function is a recursive one and it reverses the input data in place (without using an additional vector).
What are the values in arrays a, b, and c after the following code executes (list...
What are the values in arrays a, b, and c after the following code executes (list all of the elements of the arrays)? double[] a = new double[4]; double[] b = {6,4,2}; a[a.length-1] = b[b.length-1]; double[] c = b; c[0] = -1; b[1] = c[2]; c = a; c[0] = -2; a[1] = c[3];
Write a  program in C++ using a vector to create the following output. Declare a vector named  numbers    -  Don’t...
Write a  program in C++ using a vector to create the following output. Declare a vector named  numbers    -  Don’t specify a size and don’t initialize with values. Starting with 2, pushing these into the back of the vector:   2, 4, 6, 8, 10 vector capacity (array size) changes and is dependent on the compiler. The size of the list is now 5. The vector capacity (array size) is 6. The back element is: 10 The front element is: 2 Now deleting the value at...
Here is the R code for running a t-test: t.test( numeric vector of data values, another...
Here is the R code for running a t-test: t.test( numeric vector of data values, another optional numeric vector of data values,        alternative = c("two.sided", "less", "greater"),        mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-) 1.) Suppose 30 students are all taking the same Math 115 and English 101 classes at CSUN. You want to know in which class students tend to do better. The data below represents the class averages of the students in both classes....
Here is the R code for running a t-test: t.test( numeric vector of data values, another...
Here is the R code for running a t-test: t.test( numeric vector of data values, another optional numeric vector of data values,        alternative = c("two.sided", "less", "greater"),        mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-) 2) You want to determine if the average height of men in California is greater than the average height of men in Nebraska. You take a random sample of 30 men in California and 30 men in Nebraska. The data below represents...
Make a python code. Write a function named max that accepts two integer values as arguments...
Make a python code. Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Write the program as a loop that...
Find the 95% confidence interval of the mean of a vector in r code. The vector...
Find the 95% confidence interval of the mean of a vector in r code. The vector length is 100.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT