Exam 16: Searching and Sorting

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

For a list of length n, the bubble sort makes exactly ____ key comparisons.

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

A

The code shown represents the ____________________ search algorithm. The code shown represents the ____________________ search algorithm.

Free
(Short Answer)
4.7/5
(33)
Correct Answer:
Verified

sequential

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.

Free
(True/False)
4.9/5
(34)
Correct Answer:
Verified

True

Consider the following list: int list[] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95} When performing a binary search, the element to be found is first compared with ____.

(Multiple Choice)
4.7/5
(36)

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.9/5
(32)

Assume that n = 1000. To sort the list, insertion sort makes about 250,000 item assignments.

(True/False)
4.8/5
(47)

Sequential search typically searches ____.

(Multiple Choice)
4.9/5
(33)

A(n) ____________________ search uses the "divide and conquer" technique to search the list.

(Short Answer)
4.8/5
(37)

A sequential search is much faster than a binary search.

(True/False)
4.8/5
(28)

If the search item is the 900th item in the list, the sequential search makes ____ key comparisons to determine whether the search item is in the list.

(Multiple Choice)
4.8/5
(41)

All of the values in a list have the same type.

(True/False)
4.9/5
(30)

The formula to find the index of the middle element of a list is ____.

(Multiple Choice)
4.9/5
(34)

The type vector provides the function ____________________, which returns the first element in the vector object.

(Short Answer)
4.7/5
(43)

The insertion sort algorithm sorts the list by moving each element to its proper place.

(True/False)
4.8/5
(36)

In the bubble sort algorithm, which code accomplishes swapping values in elements at positions index and index + 1?

(Multiple Choice)
4.9/5
(32)

Which statement declares intList to be an empty vector?

(Multiple Choice)
4.7/5
(37)

If you want to use the class vector in your program, you must include the following statement: ____________________.

(Short Answer)
4.9/5
(36)

The sequential search algorithm uses a(n) ____ variable to track whether the item is found.

(Multiple Choice)
4.8/5
(33)

For a list size of 1000, on average, the sequential search makes about ____________________ key comparisons.

(Short Answer)
4.7/5
(34)

In a sequential search, if a search item is not in a list of 1000 elements, then ____ key comparisons will be made.

(Multiple Choice)
4.8/5
(38)
Showing 1 - 20 of 46
close modal

Filters

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