Question
An algorithm to find the length of the longest monotonically increasing sequence of numbers in an array is given below.
Let denote the length of the longest monotonically increasing sequence starting at index in the array.
Initialize .
For all such that :
Finally the length of the longest monotonically increasing sequence is .
Which of the following statements is TRUE?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2011 answer key
Solution
Classify the given recurrence and memoization scheme among algorithm design paradigms.
- The algorithm computes optimal solutions to subproblems (the length of the longest increasing sequence starting at index ) using the recurrence:
- The subproblems exhibit optimal substructure and overlapping subproblems: the solution for depends directly on the already-computed value of .
- The algorithm evaluates subproblems in reverse order (from index down to 0) and stores the intermediate results in a table , which is the classic bottom-up dynamic programming paradigm.
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2011 Computer Science and Information Technology (CS)
- Question
- 25 of 65, printed as CS Q.25
- 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.