Deck 9: Searching, Sorting, and Algorithm Analysis

Full screen (f)
exit full mode
Question
The linear search is adequate for searching through arrays, but not through ones.

A)char, string
B)any regular, vector
C)int, double
D)ascending, descending
E)small, large
Use Space or
up arrow
down arrow
to flip the card.
Question
A sorting algorithm can be used to arrange a set of in order.

A)numeric values, ascending
B)strings, ascending
C)strings, descending
D)numeric values, descending
E)All of the above.
Question
We can estimate the of an algorithm by counting the number of steps it requires to solve a problem.

A)code quality
B)number of lines of code
C)run time
D)efficiency
E)result
Question
When an array is sorted from highest to lowest, it is said to be in order.

A)ascending
B)forward
C)downward
D)reverse
E)descending
Question
If a binary search is used to search for the number 4 in the 11- element array shown below, which value will the 4 be compared to first? <strong>If a binary search is used to search for the number 4 in the 11- element array shown below, which value will the 4 be compared to first?  </strong> A)1 B)7 C)8 D)9 E)17 <div style=padding-top: 35px>

A)1
B)7
C)8
D)9
E)17
Question
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

A)it has examined all the elements in the array.
B)array index first > array index last.
C)it finds a value larger than the search key.
D)Boolean variable found equals true.
E)Boolean variable found equals false.
Question
A(n)search is more efficient than a(n)search.

A)integer, double
B)string, double
C)binary, linear
D)linear, binary
E)None of the above. All searches are equally efficient.
Question
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

A)swap the entire two objects.
B)examine a different data member.
C)swap one- by- one all data members in the two objects.
D)swap these two data values.
E)stop the sort.
Question
The search is adequate for searching through small arrays, but not through large ones.

A)random
B)selection
C)binary
D)linear
E)bubble
Question
To locate a value that is in an ordered array of 50 items, linear search must examine at most values.

A)1
B)6
C)25
D)50
E)51
Question
A(n)algorithm arranges data into some order.

A)sorting
B)searching
C)binary
D)linear
E)ordering
Question
We can measure the complexity of an algorithm that solves a computational problem by determining the number of for an input of size n.

A)times it loops
B)basic steps it requires
C)operations it performs
D)variables it uses
E)output statements it has
Question
The advantage of a linear search is that

A)it is simple.
B)it is efficient.
C)it is fast.
D)it can be used on unordered data.
E)both A and D
Question
A _ search uses a loop to sequentially step through an array.

A)linear
B)binary
C)bubble
D)relative
E)unary
Question
To locate a value in an ordered array of 50 items, binary search must examine at most values.

A)1
B)6
C)10
D)25
E)50
Question
Selection sort requires passes to put n data items in order.

A)n/2 +1
B)n/2
C)n+1
D)n
E)n- 1
Question
Sorted data can be ordered

A)using a selection sort algorithm.
B)using a bubble sort algorithm.
C)from highest to lowest value.
D)from lowest to highest value.
E)in all of the above ways.
Question
A search can be performed on an array of

A)strings.
B)integers.
C)objects.
D)all of the above.
E)A and B, but not C.
Question
The sort usually performs fewer exchanges than the sort.

A)selection, bubble
B)bubble, selection
C)linear, bubble
D)linear, binary
E)binary, linear
Question
The sort usually performs more exchanges than the sort.

A)binary, linear
B)linear, bubble
C)bubble, selection
D)linear, binary
E)selection, bubble
Question
Bubble sort and selection sort can also be used with STL vectors.
Question
A binary search begins by examining the _ element of an array.

A)smallest
B)last
C)largest
D)middle
E)first
Question
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.
Question
To determine that a item is not in an unordered array of 100 items, linear search must examine an average of values.

A)7
B)10
C)50
D)100
E)101
Question
When sorting an array of objects or structures, one must decide which data item to sort on.
Question
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.
Question
Using a linear search, you are more likely to find an item than if you use a binary search.
Question
To determine that a value is not present in an unordered array of 50 items, linear search must examine an average of values.

A)1
B)6
C)25
D)50
E)51
Question
To find a value that is in an unordered array of 100 items, linear search must examine an average of values.

A)7
B)10
C)50
D)100
E)101
Question
When searching for a particular object in an array of objects, it is necessary to compare the to the value in each examined object's

A)key field, search key.
B)search key, public member data.
C)key field, public member data.
D)search key, private member data.
E)search key, key field.
Question
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.
Question
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.
Question
Using a binary search, you are more likely to find an item than if you use a linear search.
Question
To locate a value in an ordered array of 100 items, binary search must examine at most values.

A)7
B)10
C)50
D)100
E)101
Question
A binary search requires that the elements be in order.
Question
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/36
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 9: Searching, Sorting, and Algorithm Analysis
1
The linear search is adequate for searching through arrays, but not through ones.

A)char, string
B)any regular, vector
C)int, double
D)ascending, descending
E)small, large
E
2
A sorting algorithm can be used to arrange a set of in order.

A)numeric values, ascending
B)strings, ascending
C)strings, descending
D)numeric values, descending
E)All of the above.
E
3
We can estimate the of an algorithm by counting the number of steps it requires to solve a problem.

A)code quality
B)number of lines of code
C)run time
D)efficiency
E)result
D
4
When an array is sorted from highest to lowest, it is said to be in order.

A)ascending
B)forward
C)downward
D)reverse
E)descending
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
5
If a binary search is used to search for the number 4 in the 11- element array shown below, which value will the 4 be compared to first? <strong>If a binary search is used to search for the number 4 in the 11- element array shown below, which value will the 4 be compared to first?  </strong> A)1 B)7 C)8 D)9 E)17

A)1
B)7
C)8
D)9
E)17
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
6
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

A)it has examined all the elements in the array.
B)array index first > array index last.
C)it finds a value larger than the search key.
D)Boolean variable found equals true.
E)Boolean variable found equals false.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
7
A(n)search is more efficient than a(n)search.

A)integer, double
B)string, double
C)binary, linear
D)linear, binary
E)None of the above. All searches are equally efficient.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
8
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

A)swap the entire two objects.
B)examine a different data member.
C)swap one- by- one all data members in the two objects.
D)swap these two data values.
E)stop the sort.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
9
The search is adequate for searching through small arrays, but not through large ones.

A)random
B)selection
C)binary
D)linear
E)bubble
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
10
To locate a value that is in an ordered array of 50 items, linear search must examine at most values.

A)1
B)6
C)25
D)50
E)51
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
11
A(n)algorithm arranges data into some order.

A)sorting
B)searching
C)binary
D)linear
E)ordering
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
12
We can measure the complexity of an algorithm that solves a computational problem by determining the number of for an input of size n.

A)times it loops
B)basic steps it requires
C)operations it performs
D)variables it uses
E)output statements it has
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
13
The advantage of a linear search is that

A)it is simple.
B)it is efficient.
C)it is fast.
D)it can be used on unordered data.
E)both A and D
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
14
A _ search uses a loop to sequentially step through an array.

A)linear
B)binary
C)bubble
D)relative
E)unary
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
15
To locate a value in an ordered array of 50 items, binary search must examine at most values.

A)1
B)6
C)10
D)25
E)50
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
16
Selection sort requires passes to put n data items in order.

A)n/2 +1
B)n/2
C)n+1
D)n
E)n- 1
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
17
Sorted data can be ordered

A)using a selection sort algorithm.
B)using a bubble sort algorithm.
C)from highest to lowest value.
D)from lowest to highest value.
E)in all of the above ways.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
18
A search can be performed on an array of

A)strings.
B)integers.
C)objects.
D)all of the above.
E)A and B, but not C.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
19
The sort usually performs fewer exchanges than the sort.

A)selection, bubble
B)bubble, selection
C)linear, bubble
D)linear, binary
E)binary, linear
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
20
The sort usually performs more exchanges than the sort.

A)binary, linear
B)linear, bubble
C)bubble, selection
D)linear, binary
E)selection, bubble
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
21
Bubble sort and selection sort can also be used with STL vectors.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
22
A binary search begins by examining the _ element of an array.

A)smallest
B)last
C)largest
D)middle
E)first
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
23
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.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
24
To determine that a item is not in an unordered array of 100 items, linear search must examine an average of values.

A)7
B)10
C)50
D)100
E)101
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
25
When sorting an array of objects or structures, one must decide which data item to sort on.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
26
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.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
27
Using a linear search, you are more likely to find an item than if you use a binary search.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
28
To determine that a value is not present in an unordered array of 50 items, linear search must examine an average of values.

A)1
B)6
C)25
D)50
E)51
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
29
To find a value that is in an unordered array of 100 items, linear search must examine an average of values.

A)7
B)10
C)50
D)100
E)101
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
30
When searching for a particular object in an array of objects, it is necessary to compare the to the value in each examined object's

A)key field, search key.
B)search key, public member data.
C)key field, public member data.
D)search key, private member data.
E)search key, key field.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
31
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.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
32
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.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
33
Using a binary search, you are more likely to find an item than if you use a linear search.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
34
To locate a value in an ordered array of 100 items, binary search must examine at most values.

A)7
B)10
C)50
D)100
E)101
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
35
A binary search requires that the elements be in order.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
36
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 36 flashcards in this deck.