1
GATE CSE 2015 Set 2
MCQ (Single Correct Answer)
+2
-0.6
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 kth smallest element in an array a[ ] of size n using the partition function. We assume k≤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 arguments lists are respectively
A
(a, left_end, k) and (a + left_end + 1, n - left_end - 1, k - left_end - 1)
B
(a, left_end, k) and (a, n - left_end - 1, k - left_end-1)
C
(a + left_end + 1, n - left_end - 1, k - left_end - 1) and (a, left_end, k)
D
(a, n - left_end - 1, k - left_end - 1) and (a, left_end, k)
2
GATE CSE 2015 Set 2
MCQ (Single Correct Answer)
+1
-0.3
An unordered list contains $$n$$ distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
A
$$\Theta \left( {n\,\,\log \,\,n} \right)$$
B
$$\Theta \left( n \right)$$
C
$$\Theta \left( {\log \,\,n} \right)$$
D
$$\Theta \left( 1 \right)$$
3
GATE CSE 2015 Set 2
MCQ (Single Correct Answer)
+1
-0.3
Consider two decision problems $${Q_1},{Q_2}$$ such that $${Q_1}$$ reduces in polynomial time to $$3$$-$$SAT$$ and $$3$$-$$SAT$$ reduces in polynomial time to $${Q_2}.$$ Then which one of the following is consistent with the above statement?
A
$${Q_1}$$ is $$NP,$$ $${Q_2}$$ is $$NP$$ hard.
B
$${Q_2}$$ is $$NP,$$ $${Q_1}$$ is $$NP$$ hard.
C
Both $${Q_1}$$ and $${Q_2}$$ are in $$NP.$$
D
Both $${Q_1}$$ and $${Q_2}$$ are $$NP$$ hard.
4
GATE CSE 2015 Set 2
MCQ (Single Correct Answer)
+2
-0.6
Consider the intermediate code given below.
(1)  i = 1
(2)  j = 1
(3)  t1 = 5 ∗ i
(4)  t2 = t1 + j
(5)  t3 = 4 ∗ t2
(6)  t4 = t3
(7)  a[t4] = -1
(8)  j = j + 1
(9)  if j<=5 goto (3)
(10) i=i+1
(11) if i<5 goto (2)

The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are

A
5 and 7
B
6 and 7
C
5 and 5
D
7 and 8
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12