Sorting MCQ

1. What is recurrence for worst case of QuickSort and what is the time complexity in Worst case?

A. Recurrence is T(n) = T(n-2) + O(n) and time complexity is O(n^2)
B. Recurrence is T(n) = T(n-1) + O(n) and time complexity is O(n^2)
C. Recurrence is T(n) = 2T(n/2) + O(n) and time complexity is O(nLogn)
D. Recurrence is T(n) = T(n/10) + T(9n/10) + O(n) and time complexity is O(nLogn)

View Answer

2. Which of the following is not a stable sorting algorithm?

A. Insertion sort
B. Selection sort
C. Bubble sort
D. Merge sort

View Answer

3. What is an external sorting algorithm?

A. Algorithm that uses tape or disk during the sort
B. Algorithm that uses main memory during the sort
C. Algorithm that involves swapping
D. Algorithm that are considered ‘in place’

View Answer

4. If the number of records to be sorted is small, then …… sorting can be efficient.

A. Merge
B. Heap
C. Selection
D. Bubble

View Answer

5.Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort.

A. O(n^2 Logn)
B. O(n^2)
C. O(n Logn Logn)
D. O(nLogn)

View Answer

6. Which of the following is not an in-place sorting algorithm?

A. Selection sort
B. Heap sort
C. Quick sort
D. Merge sort

View Answer

7. What is the advantage of bubble sort over other sorting techniques?

A. It is faster
B. Consumes less memory
C. Detects whether the input is already sorted
D. All of the mentioned

View Answer

8.The complexity of sorting algorithm measures the …… as a function of the number n of items to be sorter.

A. average time
B. running time
C. average-case complexity
D. case-complexity

View Answer

9. Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:
    2 5 1 7 9 12 11 10
    Which statement is correct?

A. The pivot could be either the 7 or the 9.
B. The pivot could be the 7, but it is not the 9
C. The pivot is not the 7, but it could be the 9
D. Neither the 7 nor the 9 is the pivot.

View Answer

10.Consider the situation in which assignment operation is very costly. Which of the following sorting algorithm should be performed so that the number of assignment operations is minimized in general?

A. Insertion sort
B. Selection sort
C. Heap sort
D. None

View Answer

Also Check :


* You must be logged in to add comment.