Sorting
Q22.
The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order ofQ23.
Let P be a quicksort program to sort numbers in ascending order. Let t_{1} and t_{2} be the time taken by the program for the inputs \left[1 \ 2 \ 3 \ 4\right] and \left[5 \ 4 \ 3 \ 2 \ 1\right], respectively. Which of the following holds?Q24.
In a permutation a_1.....a_n of n distinct integers, an inversion is a pair (a_i, a_j) such that i \lt j and a_i \gt a_j. What would be the worst case time complexity of the insertion Sort algorithm, if the inputs are restricted to permutations of 1....n with at most n inversions?Q25.
A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation isQ26.
You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance isQ27.
Which of the following sorting algorithms has the minimum running time complexity in the best and average case?Q28.
If we use Radix Sort to sort n integers in the range \left (n^{k/2}, n^k \right ), for some k>0 which is independent of n, the time taken would be?Q29.
What is the number of swaps required to sort n elements using selection sort, in the worst case?Q30.
Suppose you are provided with the following function declaration in the C programming language. int partition(int a[ ], int n); The function treats the first element of a[] as a pivot, and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right part. In addition, it moves the pivot so that the pivot is the last element of the left part. The return value is the number of elements in the left part. The following partially given function in the C programming language is used to find the k^{th} smallest element in an array a[ ] of size n using the partition function. We assume k \leq n int kth_smallest(int a[], int n, int k) { int left_end = partition(a,n); if ( left_end+1 == k ){ return a[left_end]; } if ( left_end+1 > k ){ return kth_smallest( ________ ); } else { return kth_smallest( ________ ); } } The missing argument lists are respectively