Chapter 9 C++ Questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?

100

If a selection sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?

2 5 3 9 7 6

To find a value that is in an unordered array of 50 items, how many values must linear search examine on average?

25

If a selection sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?

3 6 4 9 8 7

If a bubble sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?

5 3 7 2 6 9

To determine that a value is not present in an unordered array of 50 items, how many values must linear search examine on average?

50

To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?

50

To find a value in an ordered array of 50 items, how many values must binary search examine at most.

6

If a bubble sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?

6 4 8 3 7 9

If a binary search is used to search for the number 4 in the 11-element array shown here int A[] = {1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 17}; which value will the 4 be compared to first?

7

To find a value in an ordered array of 100 items, how many values must binary search examine at most?

7

If the item being searched for is NOT in the array, binary search stops looking for it and reports that it is not there when

array index first> array index last.

We can measure the complexity of an algorithm that solves a computational problem by determining the number of ________ for an input of size n.

basic steps it requires

A(n) ______ search is more efficient than a(n) ______ search.

binary, linear

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

bubble, selection

We can estimate the ________ of an algorithm by counting the number of basic steps it requires to solve a problem.

efficiency

Sorted data can be ordered

for highest to lowest, from lowest to highest, using a bubble sort algorithm, or using a selection sort algorithm

A search can be performed on an array of

integers, strings, or objects whether the data is in order or not.

The advantage of a linear search is that

it is simple and it can be used on unordered data.

A ________ search uses a loop to sequentially step through an array.

linear

The ________ search is adequate for searching through small arrays, but not through large ones.

linear

A binary search begins by examining the ______ element of an array.

middle

Selection sort requires ________ passes to put n data items in order.

n-1

A sorting algorithm can be used to arrange a set of ______ in ______ order.

numeric values or strings in either ascending or descending order

True/False: If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithm A is considered to be more efficient than Algorithm B.

FALSE

True/False: Using a binary search, you are more likely to find an item than if you use a linear search.

FALSE

True/False: Using a linear search, you are more likely to find an item than if you use a binary search.

FALSE

True/False: When an array is sorted from highest to lowest, it is said to be in ascending order.

FALSE

True/False: When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.

FALSE

True/False: When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, those two data values should be swapped.

FALSE

If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.

TRUE

True/False: A binary search requires that the elements be in order.

TRUE

True/False: Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.

TRUE

True/False: Bubble sort and selection sort can also be used with STL vectors.

TRUE

True/False: When searching for a particular object in an array of objects, it is necessary to compare the search key to the value in each examined object's key field.

TRUE

True/False: When sorting an array of objects or structures, one must decide which data item to sort on.

TRUE

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

selection, bubble

The linear search is adequate for searching through ______ arrays, but not through ______ ones.

small, large

A(n) ________ algorithm arranges data into some order.

sorting

When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, it is necessary to

swap the entire two objects.


संबंधित स्टडी सेट्स

chapter 4 (and questions on paper)

View Set

23.5 The Long-Run Industry Situation: Exit and Entry

View Set

Chapter 3: Evaluating Moral Arguments

View Set