Exam 16: Searching, Sorting and the Vector Type
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of C50 Questions
Exam 3: Inputoutput50 Questions
Exam 4: Control Structures I Selection50 Questions
Exam 5: Control Structures II Repetition50 Questions
Exam 6: User-Defined Functions50 Questions
Exam 7: User-Defined Simple Data Types, Namespaces, and the String Type50 Questions
Exam 8: Arrays and Strings50 Questions
Exam 9: Records Structs50 Questions
Exam 10: Classes and Data Abstraction49 Questions
Exam 11: Inheritance and Composition50 Questions
Exam 12: Pointers, Classes, Virtual Functions, and Abstract Classes50 Questions
Exam 13: Overloading and Templates50 Questions
Exam 14: Exception Handling50 Questions
Exam 15: Recursion50 Questions
Exam 16: Searching, Sorting and the Vector Type50 Questions
Exam 17: Linked Lists50 Questions
Exam 18: Stacks and Queues50 Questions
Select questions type
Sequential search typically searches ____.
Free
(Multiple Choice)
4.9/5
(35)
Correct Answer:
C
Which of the following statements declares intList to be a vector of size 5 and the element to be of type int?
Free
(Multiple Choice)
4.8/5
(42)
Correct Answer:
B
The statement ____ returns the element at the position index in vector vecList.
Free
(Multiple Choice)
4.8/5
(41)
Correct Answer:
A
For a list of length n, insertion sort makes ____ item assignments.
(Multiple Choice)
4.9/5
(33)
Assuming that list consists of the following elements, what is the result after bubble sort completes? int list[] = {2, 56, 34, 25, 73, 46, 89, 10, 5, 16};
(Multiple Choice)
4.7/5
(35)
Consider the following list. int list[] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95}
When performing a binary search for 75, after the first comparison, the search is restricted to ____.
(Multiple Choice)
4.8/5
(46)
In order to apply a(n) ____________________ search, the list must be sorted.
(Short Answer)
4.8/5
(27)
During the sorting phase of insertion sort, the array containing the list is divided into two sublists, sorted and unsorted.
(True/False)
4.8/5
(29)
The code below represents the ____________________ search algorithm.
int unknownSearch(const int list[], int listLength, int searchItem)
{
int loc;
bool found = false;
loc = 0;
while (loc < listLength && !found)
if (list[loc] == searchItem)
found = true;
else
loc++;
if (found)
return loc;
else
return -1;
}
(Short Answer)
4.8/5
(40)
The first element in a vector object is at location ____________________.
(Short Answer)
4.9/5
(39)
Assume that n = 1000. To sort the list, insertion sort makes about 250,000 item assignments.
(True/False)
4.9/5
(31)
The sequential search algorithm uses a(n) ____ variable to track whether the item is found.
(Multiple Choice)
4.8/5
(35)
The performance of bubble sort can be improved if we stop the sorting process as soon as we find that, in an iteration, no swapping of elements takes place.
(True/False)
4.8/5
(35)
The sequential search algorithm does not assume that the list is sorted.
(True/False)
4.7/5
(28)
The type vector provides the expression ____________________, which inserts a copy of elem into vecList at the end.
(Short Answer)
4.9/5
(44)
The statement ____ creates the vector object vecList of size size.
(Multiple Choice)
4.8/5
(37)
A(n) ____________________ search uses the "divide and conquer" technique to search the list.
(Short Answer)
4.8/5
(44)
For a list size of 1000, on average, the sequential search makes about ____________________ key comparisons.
(Short Answer)
4.9/5
(33)
____ is one of the basic operations that may be performed on a list.
(Multiple Choice)
4.9/5
(32)
After the second iteration of bubble sort for a list of length n, the last ____ are sorted.
(Multiple Choice)
4.9/5
(42)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)