Algorithm


Q201.

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
GateOverflow

Q202.

Which one the following in place sorting algorithms needs the minimum number of swaps?
GateOverflow

Q203.

Selection sort algorithm design technique is an example of
GateOverflow

Q204.

A sorting technique is called stable if
GateOverflow

Q205.

The average case and worst case complexities for Merge sort algorithm are
GateOverflow

Q206.

The usual \Theta (n^{2}) implementation of Insertion Sort to sort ab array uses linear search to identify the position where an element is to be inserted into the already sorted part of the array. If, instead, we use binary search to identify the position, the worst case running time will
GateOverflow

Q207.

Quick-sort is run on two inputs shown below to sort in ascending order taking first element as pivot (i). 1, 2, 3, \dots n (ii). n, n-1, n-2, \dots, 2, 1 Let C_1 and C_2 be the number of comparisons made for the inputs (i) and (ii) respectively. Then,
GateOverflow

Q208.

Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?
GateOverflow

Q209.

Which one of the following in place sorting algorithms needs the minimum number of swaps?
GateOverflow

Q210.

The number of elements that can be sorted in \Theta (log n) time using heap sort is
GateOverflow