Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 1 Assume that the following statements have been executed: vector a, b(

ID: 3717717 • Letter: Q

Question

QUESTION 1

Assume that the following statements have been executed:

vector a, b(5), c(5, 1), d(5);

d.push_back(77);

d.push_back(88);

The capacity of c is  and its size is .

  

QUESTION 2

Assume that the following statements have been executed:

vector a, b(5), c(5, 1), d(5);

d.push_back(77);

d.push_back(88);

The output of the following:

d.pop_back();

for (int j = 0; j < d.size(); j++)

  cout << c[j] << ' ';

is: __________________________

  

QUESTION 3

If you have to add or delete the elements anywhere in a list, which data structure should you use?

Vector

Recursion

Stack

Array

None of the above.

QUESTION 4

Assume that the following statements have been executed:

vector a, b(5), c(5, 1), d(5);

d.push_back(77);

d.push_back(88);

The output of the following for loop:

for (int j = 0; j < c.size(); j++)

cout << c[ j ] << ' ';

is: __________________________

  

QUESTION 5

Assume the declarations:

vector xValue;

vector number(5, 1);

The content of the vector after the following statement is executed:

for (int j = 0; j < 5; j++)

if (j % 2 == 0)

number.push_back(2 * j);

else

number.push_pack(2 * j + 1);

is:________________________

A.

Vector

B.

Recursion

C.

Stack

D.

Array

E.

None of the above.

Explanation / Answer

1. The capacity of c is 5 and its size is 5.

2. The output of the following for loop:

d.pop_back() : 88

for loop output:

1 1 1 1 1

So, it will print:

1 1 1 1 1

3. Recursion

4. 1 1 1 1 1

5. 1, 1, 1, 1, 1, 0, 3, 4, 7, 8

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote