Filter by year

Divide and Conquer questions

Q13

GATE CS 2015 CS-1Algorithm DesignMCQ1 mark−1/3 if wrong
Match the following:

(P) Prim's algorithm for minimum spanning tree
(Q) Floyd-Warshall algorithm for all pairs shortest paths
(R) Mergesort
(S) Hamiltonian circuit

(i) Backtracking
(ii) Greedy method
(iii) Dynamic programming
(iv) Divide and conquer
Show answer without attempting

Answer: C

Q47

GATE CS 2015 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
Given below are some algorithms, and some algorithm design paradigms.

1. Dijkstra's Shortest Path
2. Floyd-Warshall algorithm to compute all pairs shortest path
3. Binary search on a sorted array
4. Backtracking search on a graph

i. Divide and Conquer
ii. Dynamic Programming
iii. Greedy design
iv. Depth-first search
v. Breadth-first search

Match the above algorithms on the left to the corresponding design paradigm they follow.
Show answer without attempting

Answer: C

Q49

GATE CS 2015 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
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 kthk^{th} smallest element in an array a[] of size n using the partition function. We assume k≤nk \le 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
Show answer without attempting

Answer: A

0/30 correct0 marks

Related topics in Algorithm Design