Any decision tree that sorts n elements has height ________.
Ω(n lg n)
A comparison sort can be modelled as a binary decision tree: every internal node is one comparison and every leaf is one possible output ordering of the input.
Step 1 — For a correct sort every one of the n! permutations of the input must appear as a reachable leaf, so the tree needs at least n! leaves.
Step 2 — A binary tree of height h has at most \(2^h\) leaves, so \(2^h \ge n!\) and \(h \ge \lg(n!)\).
Step 3 — By Stirling's approximation \(\lg(n!) = \Theta(n \lg n)\), so the height of any such tree is \(\Omega(n \lg n)\). This is why no comparison sort can beat n lg n comparisons in the worst case.
Ω(lg n) and Ω(n) are true but weaker lower bounds and do not describe the tight bound, while Ω(n2) is false because merge sort and heapsort produce decision trees of height O(n lg n).
Ω(n lg n) option is correct.
Any decision tree that sorts n elements has height
You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which of the following sorting method would be most suitable for such a task ?
If there are n integers to sort, each integer has d digits and each digit is in the set {1, 2, ..., k}, radix sort can sort the numbers in :
An ideal sort is an in-place-sort whose additional space requirement is __________.
Which of the following algorithms sort n integers, having the range 0 to \((n^{2}-1)\), in ascending order in \(O(n)\) time ?
Suppose that the splits at every level of quicksort are in the proportion \((1 - \alpha)\) to \(\alpha\), where \(0 \lt \alpha \le \frac{1}{2}\) is a constant. The minimum depth of a leaf in the recursion tree is approximately given by
Mergesort makes two recursive calls. Which statement is true after these two recursive calls finish, but before the merge step ?
Select the Sorting Algorithms that are stable.
(A) Quick Sort
(B) Bubble Sort
(C) Insertion Sort
(D) Merge Sort
(E) Shell Sort
Choose the correct answer from the options given below :
What is the worst case time complexity of bubble sort?
The pseudocode of a function fun() is given below:
fun(int A[0, …, n-1]) {
for i = 0 to n - 2
for j = 0 to n - i - 2
if (A[j] > A[j + 1])
then swap A[j] and A[j + 1]
}
Let 𝐴[0, … ,29] be an array storing 30 distinct integers in descending order. The number of swap operations that will be performed, if the function fun() is called with 𝐴[0, … ,29] as argument, is __________. (Answer in integer)
Any decision tree that sorts n elements has height
You have to sort a list L, consisting of a sorted list followed by a few ‘random’ elements. Which of the following sorting method would be most suitable for such a task ?