ANSWERS
When an array is passed to a function, it is actually ________ the array that is passed. -
Answer-the starting memory address of
True/False: When you pass an array as an argument to a function, the function can
modify the contents of the array, affecting it even after the function is complete. -
Answer-true
A two-dimensional array can be viewed as - Answer-a table with rows and columns.
True/False: When you create a vector it is unnecessary to specify how many elements it
will hold because it will expand in size as you add new values to it. - Answer-true
True/False: After carrying out the following two statements, sales will have been created
as a one-dimensional array that can hold 20 double values.typedef salesArray
double[20];salesArray sales; - Answer-true
True/False: The amount of memory used by an array depends solely on the number of
elements the array can hold. - Answer-false
You can assign the contents of one array to another by using - Answer-none of the
above
If the scores array is defined like this:int scores[ ]= {4, 7, 4, 8, 9};what will the following
statement display?cout << scores[4]; - Answer-9
Subscript numbering in C++ - Answer-automatically begins with zero.
True/False: The following statement initializes all five elements of the number array to
1.int number[5] = {1}; - Answer-false
Unlike regular variables, arrays can hold multiple - Answer-values
To access an array element, use the array name and the element's - Answer-subscript
True/False: C++ allows a vector to be created with no elements in it. - Answer-true
If the array defined as int myArray[20][10] is being passed to a function named
displayArray, along with information on the number of rows and number of columns,
which of the following function calls is correct? - Answer-displayArray(myArray, 20, 10);
, True/False: The following array definition is legal because C++ allows arrays to be
implicitly sized.int grades[ ]; - Answer-False
A(n) ________ algorithm arranges data into some order. - Answer-sorting
When sorting an array of objects, if the values in the data member being sorted on are
out of order for two objects, it is necessary to - Answer-swap the entire two objects.
Selection sort requires ________ passes to put n data items in order. - Answer-n-1
To locate a value in an ordered array of 100 items, binary search must examine at most
________ values. - Answer-7
A(n) ________ search is more efficient than a(n) ________ search. - Answer-binary,
linear
To determine that a item is not in an unordered array of 100 items, linear search must
examine an average of ________ values. - Answer-100
True/False: A binary search requires that the elements be in order. - Answer-true
The ________ sort usually performs more exchanges than the ________ sort. -
Answer-bubble, selection
If a selection sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what
order will the data be in after the first pass of the sort is completed? - Answer-3 6 4 9 8
7
A search can be performed on an array of - Answer-strings.
integers.
objects.
all of the above.
True/False: Using a linear search, you are more likely to find an item than if you use a
binary search. - Answer-false
If the item being searched for is not in the array, binary search stops looking for it and
reports that it is not there when - Answer-array index first > array index last.
A ________ search uses a loop to sequentially step through an array. - Answer-linear
When an array is sorted from highest to lowest, it is said to be in ________ order. -
Answer-descending