Exam 16: Searching, Sorting and the Vector Type

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Sequential search typically searches ____.

Free
(Multiple Choice)
4.9/5
(35)
Correct Answer:
Verified

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:
Verified

B

The statement ____ returns the element at the position index in vector vecList.

Free
(Multiple Choice)
4.8/5
(41)
Correct Answer:
Verified

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) { \quad int loc; \quad bool found = false; \quad loc = 0; \quad while (loc < listLength && !found) \quad\quad if (list[loc] == searchItem) \quad\quad\quad found = true; \quad\quad else \quad\quad\quad loc++; \quad if (found) \quad\quad return loc; \quad else \quad\quad 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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)