Question
Consider the following table:
| Algorithm | Design Paradigm |
|---|---|
| (P) Kruskal | (i) Divide and Conquer |
| (Q) Quicksort | (ii) Greedy |
| (R) Floyd-Warshall | (iii) Dynamic Programming |
Match the algorithms to the design paradigms they are based on.
Official answer and solution
- Official answer
- C
- From
- Official GATE 2017 answer key
Solution
Identify the foundational algorithmic design paradigm used by each of the given classic algorithms.
Examine the algorithms one by one:
- Kruskal's algorithm: It finds a Minimum Spanning Tree (MST) by sorting all edges by weight and greedily picking the smallest edge that does not form a cycle. Hence, Kruskal is based on the Greedy design paradigm (P) matches (ii).
- Quicksort: It picks a pivot element, partitions the array into sub-arrays of elements smaller and larger than the pivot, and recursively sorts the sub-arrays. Hence, Quicksort is based on the Divide and Conquer paradigm (Q) matches (i).
- Floyd-Warshall algorithm: It computes all-pairs shortest paths by iteratively considering each intermediate vertex as a possible shortcut, storing and reusing solutions to subproblems in a matrix. Hence, Floyd-Warshall is based on Dynamic Programming (R) matches (iii).
Combining these matches gives (P) - (ii), (Q) - (i), (R) - (iii), which is Option C.
Final answer
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 1
- Question
- 5 of 65, printed as CS Q.5
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.