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?
View worked solution
Answer: A
To determine the correct paradigm, let's analyze the given recurrence relation and algorithm:
- Subproblem Definition: Let be the length of the longest monotonically increasing sequence starting at index .
- Overlapping Subproblems & Optimal Substructure: The value of directly depends on the already computed value of : This demonstrates optimal substructure (the optimal solution to a larger problem incorporates the optimal solution to a smaller subproblem) and overlapping subproblems.
- Computation: We compute the values of from right to left (starting from down to ) and store them in an array . This bottom-up tabulation is the hallmark of the Dynamic Programming paradigm.
Complexity Analysis:
- The algorithm performs a single pass from down to .
- At each step , it does a constant number of operations ().
- Thus, the time complexity is , which is linear.
Evaluating the Options:
- Option A: Correct. The algorithm uses the dynamic programming paradigm.
- Options B & C: Incorrect. Branch and bound is typically used for optimization problems in search spaces (like TSP or Knapsack) using a state-space tree, which is not the case here.
- Option D: Incorrect. Divide and conquer divides the problem into independent subproblems (like Merge Sort), whereas here the subproblems are overlapping and solved sequentially.
Free practice · Your answers on this page are not saved.
