Exam 14: Applications of Arrays Searching and Sorting and Strings

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

A selection sort always starts with the middle element of the list.

Free
(True/False)
5.0/5
(39)
Correct Answer:
Verified

False

The insertion sort algorithm sorts a list by repeatedly inserting an element in its proper place into a sorted sublist.

Free
(True/False)
4.7/5
(43)
Correct Answer:
Verified

True

Consider the following list.list = {5, 11, 25, 28, 45, 78, 100, 120, 125};Suppose that binary search as discussed in the book is used to determine whether 28 is in list. Exactly how many key comparisons are executed by binary search?

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

B

Suppose that you have the following list.int[] list = {5, 10, 15, 20, 25, 30, 35, 40, 45};Further assume that binary search is used to determine whether 20 is in list. When the loop terminates, the value of the index variable first is 3.

(True/False)
4.8/5
(38)

Consider the following list.list = {5, 11, 25, 28, 45, 78, 100, 120, 125};Suppose that binary search as discussed in the book is used to determine whether 110 is in list. What are the values of first and last when the while loop, in the body of the binarySearch method, terminates?

(Multiple Choice)
4.7/5
(46)

In selection sort, initially, the entire list, that is, list[0]...list[listLength], is the unsorted list.

(True/False)
4.8/5
(39)

Why can't a binary search be used on the list as it appears in the accompanying figure?

(Multiple Choice)
4.9/5
(42)

In a selection sort, a list is sorted by selecting elements in the list, one at a time, and moving them to their proper positions.

(True/False)
4.8/5
(35)

In a sequential search, how many key comparisons would have to be made on the list in the accompanying figure to find the number 5?

(Multiple Choice)
4.8/5
(38)

In insertion sort, during the sorting phase the array containing the list is divided into three sublists.

(True/False)
4.8/5
(35)

A sequential search is most efficient for large lists.

(True/False)
4.8/5
(38)

On average in a sequential search, how many comparisons would have to be made to find an element in the list in the accompanying figure?

(Multiple Choice)
4.9/5
(35)

If the list in the accompanying figure was to be searched for the number 44 using a binary search, how many key comparisons would have to be made?

(Multiple Choice)
4.8/5
(37)

Consider the following list.list = {24, 20, 10, 75, 70, 18, 60, 35}Suppose that list is sorted using the selection sort algorithm as discussed in the book. What is the resulting list after two passes of the sorting phase; that is, after two iterations of the outer for loop?

(Multiple Choice)
4.8/5
(31)

Suppose that you have the following list.int[] list = {2, 4, 6, 8, 10, 12, 14, 16};Further assume that binary search is used to determine whether 15 is in list. When the loop terminates, the value of the index variable last is 6.

(True/False)
4.7/5
(37)

A list is a set of related values that do not necessarily have the same type.

(True/False)
4.8/5
(35)

A sequential search is faster than a binary search on sorted lists.

(True/False)
4.9/5
(48)

A binary search can be performed on both sorted and unsorted lists.

(True/False)
4.8/5
(41)

In a sequential search, you search an array starting from the middle component.

(True/False)
5.0/5
(38)

In the binary search algorithm, two key comparisons are made through every iteration of the loop.

(True/False)
4.7/5
(33)
Showing 1 - 20 of 50
close modal

Filters

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