若要將未依大小順序排列的13張黑桃撲克牌(A~K),以選擇排序法由小到大依序排列,共需進行幾次比較?
(A)78
(B)91
(C)71
若要以氣泡排序法,將數列資料25、35、15、5、45由小到大依序排列,請問在第一次循環結束後,數列排列的狀況為何?
(A)5、35、15、25、45
(B)5、15、35、25、45
(C)25、15、5、35、45
Which case has the time complexity of O(nlogn)?
(A) The worst case time complexity of quick sort.
(D) The worst case time complexity of bubble sort.
(C) The worst case time complexity of heap sort.
Which statement is correct for the algorithm of heap sort ?
The worst case time complexity of heap sort is O(n2).
The best case time complexity of heap sort is O(nlogn).
Heap sort is a stable sorting algorithm.
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)
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(nLogn)
(B)O(n^2 Logn)
(C)O(n^2)
Which of the following is not a stable sorting algorithm in its typical implementation.
(A)Insertion Sort
(B)Merge Sort
(C)Quick 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)Counting Sort
(B)Heap Sort
(C)Insertion Sort
Given an unsorted array.
The array has this property that every element in array is
at most k distance from its position in sorted array where k is a positive integer smaller than size of array.
Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?
(A)Insertion Sort with time complexity O(kn)
(B)Heap Sort with time complexity O(nLogk)
(C)Quick Sort with time complexity O(kLogk)
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)Radix Sort