Deck 9: Searching, Sorting, Algorithm Analysis

ملء الشاشة (f)
exit full mode
سؤال
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A binary search begins by examining the ________ element of an array.

A) first
B) last
C) largest
D) middle
E) smallest
سؤال
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?

A) 2 5 3 9 7 6
B) 5 7 3 9 2 6
C) 5 3 7 2 6 9
D) 2 3 5 6 7 9
E) none of the above
سؤال
To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?

A) 7
B) 10
C) 50
D) 100
E) 101
سؤال
Using a linear search, you are more likely to find an item than if you use a binary search.
سؤال
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
سؤال
A(n) ________ search is more efficient than a(n) ________ search.

A) string, double
B) integer, double
C) binary, linear
D) linear, binary
E) None of the above. All searches are equally efficient.
سؤال
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.
سؤال
The ________ sort usually performs fewer exchanges than the ________ sort.

A) bubble, selection
B) selection, bubble
C) binary, linear
D) linear, binary
E) linear, bubble
سؤال
A sorting algorithm can be used to arrange a set of ________ in ________ order.

A) numeric values, ascending
B) numeric values, descending
C) strings, ascending
D) strings, descending
E) All of the above.
سؤال
To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?

A) 7
B) 10
C) 50
D) 100
E) 101
سؤال
Bubble sort and selection sort can also be used with STL vectors.
سؤال
When sorting an array of objects or structures, one must decide which data item to sort on.
سؤال
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) output statements it has
B) times it loops
C) basic steps it requires
D) variables it uses
E) operations it performs
سؤال
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) examine a different data member.
B) swap these two data values.
C) swap the entire two objects.
D) swap one-by-one all data members in the two objects.
E) stop the sort.
سؤال
The linear search is adequate for searching through ________ arrays, but not through ________ ones.

A) int, double
B) char, string
C) ascending, descending
D) small, large
E) any regular, vector
سؤال
To find a value in an ordered array of 100 items, how many values must binary search examine at most?

A) 7
B) 10
C) 50
D) 100
E) 101
سؤال
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) array index first > array index last.
B) Boolean variable found equals false.
C) Boolean variable found equals True.
D) it finds a value larger than the search key.
E) it has examined all the elements in the array.
سؤال
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?

A) 2 5 3 9 7 6
B) 5 7 3 9 2 6
C) 5 3 7 2 6 9
D) 2 3 5 6 7 9
E) none of the above
سؤال
A search can be performed on an array of

A) integers.
B) strings.
C) objects.
D) all of the above, but only if the data is in order.
E) all of the above whether the data is in order or not.
سؤال
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.
سؤال
The ________ sort usually performs more exchanges than the ________ sort.

A) bubble, selection
B) selection, bubble
C) binary, linear
D) linear, binary
E) linear, bubble
سؤال
A(n) ________ algorithm arranges data into some order.

A) sorting
B) searching
C) ordering
D) linear
E) binary
سؤال
To find a value that is in an unordered array of 50 items, how many values must linear search examine on average?

A) 1
B) 6
C) 25
D) 50
E) 51
سؤال
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.
سؤال
Sorted data can be ordered

A) from lowest to highest value.
B) from highest to lowest value.
C) using a bubble sort algorithm.
D) using a selection sort algorithm.
E) in all of the above ways.
سؤال
A ________ search uses a loop to sequentially step through an array.

A) binary
B) unary
C) linear
D) relative
E) bubble
سؤال
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?

A) 3 4 6 7 8 9
B) 3 6 4 9 8 7
C) 6 4 8 3 7 9
D) 6 8 4 9 3 7
E) None of the above
سؤال
Using a binary search, you are more likely to find an item than if you use a linear search.
سؤال
The ________ search is adequate for searching through small arrays, but not through large ones.

A) binary
B) linear
C) selection
D) bubble
E) random
سؤال
A binary search requires that the elements be in order.
سؤال
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?

A) 1
B) 7
C) 8
D) 9
E) 17
سؤال
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?

A) 3 4 6 7 8 9
B) 3 6 4 9 8 7
C) 6 4 8 3 7 9
D) 6 8 4 9 3 7
E) None of the above
سؤال
We can estimate the ________ of an algorithm by counting the number of basic steps it requires to solve a problem.

A) number of lines of code
B) efficiency
C) run time
D) code quality
E) result
سؤال
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.
سؤال
To find a value in an ordered array of 50 items, how many values must binary search examine at most.

A) 1
B) 6
C) 10
D) 25
E) 50
سؤال
When an array is sorted from highest to lowest, it is said to be in ascending order.
سؤال
Selection sort requires ________ passes to put n data items in order.

A) n
B) n / 2
C) n / 2 + 1
D) n - 1
E) n + 1
سؤال
To determine that a value is not present in an unordered array of 50 items, how many values must linear search examine on average?

A) 1
B) 6
C) 25
D) 50
E) 51
سؤال
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 Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Searching, Sorting, Algorithm Analysis
1
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
False
2
A binary search begins by examining the ________ element of an array.

A) first
B) last
C) largest
D) middle
E) smallest
D
3
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?

A) 2 5 3 9 7 6
B) 5 7 3 9 2 6
C) 5 3 7 2 6 9
D) 2 3 5 6 7 9
E) none of the above
C
4
To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?

A) 7
B) 10
C) 50
D) 100
E) 101
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
Using a linear search, you are more likely to find an item than if you use a binary search.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
A(n) ________ search is more efficient than a(n) ________ search.

A) string, double
B) integer, double
C) binary, linear
D) linear, binary
E) None of the above. All searches are equally efficient.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
The ________ sort usually performs fewer exchanges than the ________ sort.

A) bubble, selection
B) selection, bubble
C) binary, linear
D) linear, binary
E) linear, bubble
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
A sorting algorithm can be used to arrange a set of ________ in ________ order.

A) numeric values, ascending
B) numeric values, descending
C) strings, ascending
D) strings, descending
E) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?

A) 7
B) 10
C) 50
D) 100
E) 101
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
Bubble sort and selection sort can also be used with STL vectors.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
When sorting an array of objects or structures, one must decide which data item to sort on.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
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) output statements it has
B) times it loops
C) basic steps it requires
D) variables it uses
E) operations it performs
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
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) examine a different data member.
B) swap these two data values.
C) swap the entire two objects.
D) swap one-by-one all data members in the two objects.
E) stop the sort.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
The linear search is adequate for searching through ________ arrays, but not through ________ ones.

A) int, double
B) char, string
C) ascending, descending
D) small, large
E) any regular, vector
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
To find a value in an ordered array of 100 items, how many values must binary search examine at most?

A) 7
B) 10
C) 50
D) 100
E) 101
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
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) array index first > array index last.
B) Boolean variable found equals false.
C) Boolean variable found equals True.
D) it finds a value larger than the search key.
E) it has examined all the elements in the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
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?

A) 2 5 3 9 7 6
B) 5 7 3 9 2 6
C) 5 3 7 2 6 9
D) 2 3 5 6 7 9
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
A search can be performed on an array of

A) integers.
B) strings.
C) objects.
D) all of the above, but only if the data is in order.
E) all of the above whether the data is in order or not.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
The ________ sort usually performs more exchanges than the ________ sort.

A) bubble, selection
B) selection, bubble
C) binary, linear
D) linear, binary
E) linear, bubble
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
A(n) ________ algorithm arranges data into some order.

A) sorting
B) searching
C) ordering
D) linear
E) binary
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
To find a value that is in an unordered array of 50 items, how many values must linear search examine on average?

A) 1
B) 6
C) 25
D) 50
E) 51
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
Sorted data can be ordered

A) from lowest to highest value.
B) from highest to lowest value.
C) using a bubble sort algorithm.
D) using a selection sort algorithm.
E) in all of the above ways.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
A ________ search uses a loop to sequentially step through an array.

A) binary
B) unary
C) linear
D) relative
E) bubble
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
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?

A) 3 4 6 7 8 9
B) 3 6 4 9 8 7
C) 6 4 8 3 7 9
D) 6 8 4 9 3 7
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
Using a binary search, you are more likely to find an item than if you use a linear search.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
The ________ search is adequate for searching through small arrays, but not through large ones.

A) binary
B) linear
C) selection
D) bubble
E) random
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
A binary search requires that the elements be in order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
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?

A) 1
B) 7
C) 8
D) 9
E) 17
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
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?

A) 3 4 6 7 8 9
B) 3 6 4 9 8 7
C) 6 4 8 3 7 9
D) 6 8 4 9 3 7
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
We can estimate the ________ of an algorithm by counting the number of basic steps it requires to solve a problem.

A) number of lines of code
B) efficiency
C) run time
D) code quality
E) result
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
To find a value in an ordered array of 50 items, how many values must binary search examine at most.

A) 1
B) 6
C) 10
D) 25
E) 50
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
When an array is sorted from highest to lowest, it is said to be in ascending order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
Selection sort requires ________ passes to put n data items in order.

A) n
B) n / 2
C) n / 2 + 1
D) n - 1
E) n + 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
To determine that a value is not present in an unordered array of 50 items, how many values must linear search examine on average?

A) 1
B) 6
C) 25
D) 50
E) 51
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.