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).
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...
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...
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.
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a,...
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds the base address of the array A (add comments to your MIPS code). j = 0; for(i=0 ; i<a ; i++) A[i]=i+j++;
The following code was meant to print out the elements in an array in reverse order....
The following code was meant to print out the elements in an array in reverse order. However, it does not behave correctly. public static void reverse(int[] a, int index) {       if (index == (a.length - 1))         System.out.printf("%d%n", a[index]);       else {         reverse(a, index); What does it do? Explain why it behaves in this way and There is more than one error in the code. Correct the code so that it will recursively print out the elements of...
Use Matlab to introduce arow vector,f,and define it as a 1 by 4 vector showing values...
Use Matlab to introduce arow vector,f,and define it as a 1 by 4 vector showing values of 1, 2, 3and 4. Now try to build matrix D, using the following 2 commands a.D = [f ; A] b.D= [f , A] c.Which one can be built,and which one cannot be built? Explain your answer. Matrix A, which is a 4by 4 matrix, (The first, second, third and fourth column values are:2,4,6,8and 1,3,5,7 and 8,6,4,2 and 7,5,3,1 , respectively.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT