Exam 8: Searching and Sorting Arrays

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

Before you can perform a selection sort, the data must be stored in ascending order.

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

False

The following is the pseudocode for which type of algorithm? Set first to 0 Set last to the last subscript in the array Set found to False Set position to -1 While found is not true and first is less than or equal to last Set middle to the subscript halfway between array[first] and array[last] If array[middle] equals the desired value Set found to true Set position to middle Else If array[middle] is greater than the desired value Set last to middle - 1 Else Set first to middle + 1 End If End While Return position

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

C

Array elements must __________ before a binary search can be performed.

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

D

The number of comparisons made by a binary search is expressed in powers of two.

(True/False)
4.8/5
(34)

On average, an item is just as likely to be found near the beginning of an array as near the end.

(True/False)
4.8/5
(32)

The __________ sort usually performs fewer exchanges than the __________ sort.

(Multiple Choice)
4.8/5
(44)

A __________ algorithm is a method of locating a specific item of information in a larger collection of data.

(Multiple Choice)
4.8/5
(44)

The advantage of a linear search is its

(Multiple Choice)
5.0/5
(30)

Assume you have two integer variables, num1 and num2. Which of the following is the correct way to swap the values in these two variables?

(Multiple Choice)
4.7/5
(34)

When an array is sorted from highest to lowest, it is said to be in

(Multiple Choice)
4.8/5
(28)

Before you can perform a bubble sort, the data must be stored in descending order.

(True/False)
4.9/5
(40)

A(n) __________ search uses a loop to sequentially step through an array.

(Multiple Choice)
4.8/5
(30)

A __________ search is more efficient than a __________ search.

(Multiple Choice)
4.7/5
(36)

The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function? Void swap(int num1, int num2) { Int temp = num2; Num2 = num1; Num1 = temp; }

(Multiple Choice)
4.8/5
(39)

The following is the pseudocode for which type of algorithm? For start = each array subscript, from the first to the next-to-last MinIndex = start MinValue = array[start] For index = start + 1 To size - 1 If array[index] < minValue MinValue = array[index] MinIndex = index End If End For Swap array[minIndex] with array[start] End For

(Multiple Choice)
4.8/5
(27)

Algorithms used to arrange random data in some order are __________ algorithms.

(Multiple Choice)
4.9/5
(33)

The bubble sort is an easy way to arrange data in ascending order but it cannot arrange data in descending order.

(True/False)
4.7/5
(23)

The following is the pseudocode for which type of algorithm? For maxElement = each subscript in the array, from the last to the first For index = 0 To maxElement - 1 If array[index] > array[index + 1] Swap array[index] with array[index + 1] End If End For End For

(Multiple Choice)
4.8/5
(26)

The __________ is adequate for searching through small arrays.

(Multiple Choice)
4.9/5
(25)

A linear search can only be implemented with integer values.

(True/False)
4.9/5
(33)
Showing 1 - 20 of 30
close modal

Filters

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