cop2000 quiz 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

true

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

true

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

true

A ________ search is more efficient than a ________ search.

binary linear

A linear search can only be implemented with integer values

false

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

false

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

false

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

false

Using a binary search, you are more likely to find an item than if you use a linear search

false

Data that is to be sorted in ascending order is ordered

from lowest value to highest value

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

linear

The _________ is adequate for searching through small arrays.

linear

Using a linear search to find a value that is stored in the last element of an array that contains 20,000 elements, ________ elements must be compared.

20,000

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

descending order

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

search

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

selection bubble

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

selection sort

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; }

The swap function must use reference parameters.

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

binary search

A binary search begins with the _________ element of an array

middle

Regardless of the algorithm being used, a search through an array is always performed

none of these

The advantage of a linear search is its ____________

simplicity

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

sorting


Kaugnay na mga set ng pag-aaral

Prep U: Ch 3: Inflammation, the Inflammatory Response, and Fever

View Set

Chapter 5 Infection Prevention & Disease Control

View Set

Criminal Investigation 9th Edition

View Set

Communications Quiz Chapters 1-3

View Set

THE PEARL GIRL activity 4/Which word/option is right?

View Set

215- Ch. 2 Collecting Subjective Data: The Interview and Health History

View Set

Research with Prisoners, Citi Training, Assessing Risk - SBE, CITI Questions

View Set

MS3 - Ch. 15: Oncologic Disorders

View Set