What is the best time complexity of bubble sort?
A N^2
B NlogN
C N
D N(logN)^2
Assume that we use Bubble Sort to sort n distinct elements in ascending order. When does the best case of Bubble Sort occur?
A When elements are sorted in ascending order
B When elements are sorted in descending order
C When elements are not sorted by any order
D There is no best case for Bubble Sort. It always takes O(n*n) time
The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 5, 13 in ascending order, using bubble sort is
A 11
B 12
C 13
D 10
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)
Which of the following is not a stable sorting algorithm in its typical implementation.
A Insertion Sort
B Merge Sort
C Quick Sort
D Bubble Sort
Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).
A Quick Sort
B Heap Sort
C Merge Sort
D Insertion Sort
Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?
A Heap Sort
B Selection Sort
C Insertion Sort
D Merge Sort
Which of the following is not true about comparison based sorting algorithms?
A The minimum possible time complexity of a comparison based sorting algorithm is O(nLogn) for a random input array
B Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared
C Counting Sort is not a comparison based sorting algortihm
D Heap Sort is not a comparison based sorting algorithm.
No comments:
Post a Comment