Deck 19: Searching and Sorting
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/10
Play
Full screen (f)
Deck 19: Searching and Sorting
1
The choice of which sorting algorithm to use does not affect:
A) How thoroughly sorted the vector will be.
B) The time it takes for the sorting operation to complete.
C) The amount of memory used by the program.
D) All of the above will be affected by the choice of sorting algorithm.
A) How thoroughly sorted the vector will be.
B) The time it takes for the sorting operation to complete.
C) The amount of memory used by the program.
D) All of the above will be affected by the choice of sorting algorithm.
A
2
Which of the following represents the efficiency of the insertion sort?
A) O1)
B) On)
C) On2)
D) None of the above.
A) O1)
B) On)
C) On2)
D) None of the above.
C
3
Selection sort has a Big O of:
A) O2n)
B) On2)
C) O½n2)
D) On2 - n)/2 )
A) O2n)
B) On2)
C) O½n2)
D) On2 - n)/2 )
B
4
At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm?
A) 10
B) 15
C) 20
D) 30
A) 10
B) 15
C) 20
D) 30
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
5
A merge sort operation runs in:
A) Olog n) time.
B) On) time.
C) On log n) time.
D) On2) time.
A) Olog n) time.
B) On) time.
C) On log n) time.
D) On2) time.
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
6
The merge sort algorithm:
A) Can only be used on vectors of even length.
B) Works by reducing vectors down to the base case of a two-element vector.
C) Works by merging two sorted vectors into one larger sorted vector.
D) Cannot be implemented recursively.
A) Can only be used on vectors of even length.
B) Works by reducing vectors down to the base case of a two-element vector.
C) Works by merging two sorted vectors into one larger sorted vector.
D) Cannot be implemented recursively.
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
7
The first step performed by the binary search algorithm at each iteration is to:
A) Compare the search key with the lowest element in the current subvector.
B) Compare the search key with the middle element in the current subvector.
C) Compare the search key with the highest element in the current subvector.
D) Count the number of elements in the current subvector.
A) Compare the search key with the lowest element in the current subvector.
B) Compare the search key with the middle element in the current subvector.
C) Compare the search key with the highest element in the current subvector.
D) Count the number of elements in the current subvector.
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is not a valid runtime description according to Big O notation?
A) O1)
B) On)
C) On2)
D) All of the above are valid.
A) O1)
B) On)
C) On2)
D) All of the above are valid.
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is not true about searching algorithms and their efficiency?
A) The major difference between various searching algorithms is the amount of effort they require to complete the search.
B) Big O notation is one way to describe how likely it is that a searching algorithm will find its target.
C) The effort required to perform a search or a sort is particularly dependent on the number of data elements.
D) A more efficient searching algorithm is usually more complex and difficult to implement.
A) The major difference between various searching algorithms is the amount of effort they require to complete the search.
B) Big O notation is one way to describe how likely it is that a searching algorithm will find its target.
C) The effort required to perform a search or a sort is particularly dependent on the number of data elements.
D) A more efficient searching algorithm is usually more complex and difficult to implement.
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck
10
An algorithm that requires __________ operations to complete its task on n data elements is said to have a linear runtime.
A) n3 + 9
B) 3 n2 + 3 n + 2
C) 2 n + 1
D) 6
A) n3 + 9
B) 3 n2 + 3 n + 2
C) 2 n + 1
D) 6
Unlock Deck
Unlock for access to all 10 flashcards in this deck.
Unlock Deck
k this deck