Answered You can hire a professional tutor to get the answer.

QUESTION

QUESTION 5 Which code correctly swaps the integer values stored in the array data at positions first and second?

QUESTION 5

  1. Which code correctly swaps the integer values stored in the array data at positions first and second?
temp = data[first]; data[first] = temp;data[second] = data[first]; temp = data[first]; data[first] = data[second];data[second] = temp; temp = data[first]; data[first] = data[temp];data[second] = temp; temp = data[first]; data[first] = data[second];data[second] = data[first];QUESTION 6
  1. Which one of the following statements is valid for declaring a vector as a function parameter?
  1. A vector declared as a function parameter should be accompanied with its size.
  2. A vector declared as a function parameter is a reference parameter by default.
  3. An element of the vector cannot be modified in a function when the vector is declared as a parameter.
  4. An element of the vector can be modified if declared using the & sign as a function parameter.
QUESTION 7
  1. Consider the following code snippet:
myarray[] = { , , , , }; << myarray[]; << myarray[];

What is the output of the code snippet?

  1. 1050
  2. 2030
  3. 3040
  4. 4050
QUESTION 8
  1. What is the output of the following code snippet?
<> num();num.push_back(); << num.size();
  1. 1
  2. 3
  3. 4
  4. 5
QUESTION 9
  1. Consider the following line of code for calling a function named func1:
func1(vectdata, vardata);

Which one of the following function signatures is valid for func1, where vectdata is an integer vector and vardata is an integer variable?

  1. void func1(vectdata, vardata)
  2. void func1(vector vectdata, int vardata)
  3. void func1(vector<int> vectdata, int vardata)
  4. void func1(vector<int>, int)
QUESTION 10
  1. Consider the following code snippet:
<> somenum();somenum[] = ;somenum[] = ;somenum[] = ; cnt = ; ( count = ; count < somenum.size(); count++){   (somenum[count] % == )  {     cnt++;  }}

What is the value of the cnt variable after the execution of the given code snippet?

  1. 1
  2. 2
  3. 3
  4. unpredictable result
QUESTION 11

The binary search on an array requires that

  1. The array elements be in order
  2. The array elements be in random order
  3. The element that is being searched for must always be in the array
  4. The array be two dimensional
QUESTION 12
  1. In the following code fragment, the variables SIZE and count serve what roles?
SIZE = ; data[SIZE]; count = ; ; ((count < SIZE) && (cin >> )){  data[count] = ;  count++;}
  1. SIZE is the capacity of the array; count is the number of elements currently used
  2. SIZE is the number of elements used in the array; count is the array capacity
  3. SIZE is the capacity of the array; count is the number of elements that are equal to zero
  4. SIZE is the number of elements unused in the array; count is the number of inputs
QUESTION 13

Your program needs to store a sequence of integers of unknown length. Which of the following can you use?

  1. An array declared as int a[];
  2. A vector declared as vector<int> a;
  3. An array declared as int a[1000];
  4. All of the listed items.
QUESTION 14
  1. Consider the following code snippet:
number[]; number[] =

Which one of the following statements is correct for the given code snippet?

  1. Line 2 declares and initializes an array of five elements with value 5.
  2. Line 2 causes a bounds error because 5 is an invalid index number.
  3. Line 2 initializes the fifth element of the array with value 5.
  4. Line 2 initializes all the elements of the array with value 5.
QUESTION 15

Which is true when a 2D array is used as a function parameter?

  1. Only the row size must be a constant provided as an argument to the function
  2. Only the column size must be a constant provided as an argument to the function
  3. Both the row and column size must be constants provided as arguments to the function
  4. Neither the row nor the column size are necessary
QUESTION 16
  1. 38.43. What does the following code segment do to the array a[], given that the current_size variable holds the number of valid elements currently in the array?
] = a[current_size-];current_size--;
  1. It shrinks the size by 1.
  2. It changes the ordering of elements in the array.
  3. It removes the element at index pos.
  4. It does all of these things.
QUESTION 17
  1. Consider the following code snippet:
numarray[ ] = { , , , , }; << numarray[]; << numarray[];

What is the output of the code snippet?

  1. 15
  2. 14
  3. 25
  4. 04
QUESTION 18

What is the valid range of index values for an array of size 10?

  1. 0 to 10
  2. 1 to 9
  3. 1 to 10
  4. 0 to 9
QUESTION 19
  1. Consider the following code snippet:
][] = {{8, 7}, {6, 5}};cout [];

What is the output of the given code snippet?

  1. 8
  2. 8,7
  3. 87
  4. 08
QUESTION 20

The selection sort uses two primary operations to put the elements of an array in order:

  1. find the minimum; and insert
  2. find the minimum; and swap
  3. divide and conquer; and swap
  4. insert; and copy
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question