Chapter 8 Flashcards Preview

Computer Science > Chapter 8 > Flashcards

Flashcards in Chapter 8 Deck (17)
Loading flashcards...
1

Why is the linear search also called "sequential search"?

It uses a loop to sequentially step through an array, starting with the first element. It compares each element with the value being searched for, and stops when either the value is found or the end of the array is encountered

2

If a linear search function is searching for a value that is stored in the last element of a 10,000-element array, how many elements will the search code have to read to locate the value?

All 10,000 elements

3

In an average case involving an array of N elements, how many times will a linear search function have to read the array to locate a specific value?

N/2 times

4

A binary search function is searching for a value that is stored in the middle element of an array. How many times will the function read an element in the array before finding the value?

Once

5

What is the maximum number of comparisons that a binary search function will make when searching for a value in a 1,000-element array?

10 (2^10)

6

Why is the bubble sort inefficient for large arrays?

It moves the items in the array only by one element at a time

7

Why is the selection sort more efficient than the bubble sort on large arrays?

The selection sort usually performs more exchanges because it moves items immediately to their final position in the array

8

The _________ search algorithm steps sequentially through an array, comparing each item with the search value.

linear (or sequential)

9

The ______ search algorithm repeatedly divides the portion of an array being searched in half

binary

10

The _________ search algorithm is adequate for small arrays but not large arrays.

linear

11

The _________ search algorithm requires that the arrays contents be sorted.

binary

12

If an array is sorted in _________ order, the values are stored from lowest to highest.

Ascending

13

If an array is sorted in _________ order, the values are stored from highest to lowest.

Descending

14

[T/F]
If data are sorted in ascending order, it means they are ordered from lowest value to highest value.

true

15

[T/F]
If data are sorted in descending order, it means they are ordered from lowest value to highest value.

False

16

[T/F]
The average number of comparisons performed by the linear search on an
array of N elements is N/2 (assuming the search values are consistently found)

true

17

[T/F]
The maximum number of comparisons performed by the linear search on an
array of N elements is N/2 (assuming the search values are consistently found)

false