QUIZ 5B QUESTIONS DSA WITH
CORRECT ANSWERS
In BinarySearch, the best case occurs when: - Correct Answers -The item is located in
the middle of the collection.
For linear or sequential search, the average case time performance is: - Correct
Answers -O(n)
In BinarySearch, the worst case occurs when: (select all that apply) - Correct Answers -
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. - Correct Answers -B and C are
true
Which of the following is NOT true about using the compareTo() method in Java to sort
things? - Correct Answers -You could rewrite the body of your compareTo() method in
order to sort a list in descending order instead of ascending order.
Considering the relationship between a Process and a Thread - Correct Answers -A
Process can contain multiple Threads
What course of action should be followed when a thread has been interrupted (due to
an exception)? - Correct Answers -the thread should execute the code in the
appropriate catch block
A race condition, essentially, is when - Correct Answers -the order the threads complete
determines the outcome of the program.
Assume values is an array of integers that is currently filled to capacity, with the
following values:
CORRECT ANSWERS
In BinarySearch, the best case occurs when: - Correct Answers -The item is located in
the middle of the collection.
For linear or sequential search, the average case time performance is: - Correct
Answers -O(n)
In BinarySearch, the worst case occurs when: (select all that apply) - Correct Answers -
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. - Correct Answers -B and C are
true
Which of the following is NOT true about using the compareTo() method in Java to sort
things? - Correct Answers -You could rewrite the body of your compareTo() method in
order to sort a list in descending order instead of ascending order.
Considering the relationship between a Process and a Thread - Correct Answers -A
Process can contain multiple Threads
What course of action should be followed when a thread has been interrupted (due to
an exception)? - Correct Answers -the thread should execute the code in the
appropriate catch block
A race condition, essentially, is when - Correct Answers -the order the threads complete
determines the outcome of the program.
Assume values is an array of integers that is currently filled to capacity, with the
following values: