Quiz 5B Questions DSA
In Binary Search, the best case occurs when: - answer The item is located in the middle
of the collection.
For linear or sequential search, the average case time performance is: - answer O(n)
In Binary Search, the worst case occurs when: (select all that apply) - answer The item
is not in the collection.
The item is located at the very beginning of the collection.
The item is located at the end of the collection.
Which of the following statements about QuickSort and Mergesort are true?
A. Mergesort is not an example of the divide and conquer algorithm design strategy
because it only does Θ(1) work to divide the problem into two subproblems.
B. Quicksort has a better space-complexity than mergesort because partition() has
space-complexity of Θ(1) while merge() has space-complexity of Θ(n).
C. Both sorts can be made into hybrid sorts by using a non-recursive sort like insertion
sort to process subproblems smaller than a certain size. - answerB and C are true
Which of the following is NOT true about using the compareTo() method in Java to sort
things? - answerYou could rewrite the body of your compareTo() method in order to sort
a list in descending order instead of ascending order.
Assume values is an array of integers that is currently filled to capacity, with the
following values:
9 4 12 2 6 8 18
Which of the following lists of numbers would accurately show the array after the fourth
pass of Insertion sort? - answer2, 4, 6, 9, 12, 8, 18
A vector contains the numbers <7, 2, 9, 5, 4, 1> and Insertion Sort is run on this list.
Which of the following list orderings will never occur during any step of the sorting
process? We are only concerned with the state of the list at the beginning of each
iteration of the outer loop (after each element is fully "inserted"). - answer2, 7, 9, 4, 5, 1
Assume values is an array of integers that is currently filled to capacity, with the
following values:
9 4 12 2 6 8 18
Which of the following lists of numbers would accurately show the array after the fourth
pass of Selection sort? - answer2, 4, 6, 8, 12, 9, 18
In Binary Search, the best case occurs when: - answer The item is located in the middle
of the collection.
For linear or sequential search, the average case time performance is: - answer O(n)
In Binary Search, the worst case occurs when: (select all that apply) - answer The item
is not in the collection.
The item is located at the very beginning of the collection.
The item is located at the end of the collection.
Which of the following statements about QuickSort and Mergesort are true?
A. Mergesort is not an example of the divide and conquer algorithm design strategy
because it only does Θ(1) work to divide the problem into two subproblems.
B. Quicksort has a better space-complexity than mergesort because partition() has
space-complexity of Θ(1) while merge() has space-complexity of Θ(n).
C. Both sorts can be made into hybrid sorts by using a non-recursive sort like insertion
sort to process subproblems smaller than a certain size. - answerB and C are true
Which of the following is NOT true about using the compareTo() method in Java to sort
things? - answerYou could rewrite the body of your compareTo() method in order to sort
a list in descending order instead of ascending order.
Assume values is an array of integers that is currently filled to capacity, with the
following values:
9 4 12 2 6 8 18
Which of the following lists of numbers would accurately show the array after the fourth
pass of Insertion sort? - answer2, 4, 6, 9, 12, 8, 18
A vector contains the numbers <7, 2, 9, 5, 4, 1> and Insertion Sort is run on this list.
Which of the following list orderings will never occur during any step of the sorting
process? We are only concerned with the state of the list at the beginning of each
iteration of the outer loop (after each element is fully "inserted"). - answer2, 7, 9, 4, 5, 1
Assume values is an array of integers that is currently filled to capacity, with the
following values:
9 4 12 2 6 8 18
Which of the following lists of numbers would accurately show the array after the fourth
pass of Selection sort? - answer2, 4, 6, 8, 12, 9, 18