Question: A subsequence is an array derived from another array by removing some or no elements, while keeping the order of the remaining elements the same.
A subsequence is an array derived from another array by removing
some or no elements, while keeping the order of the remaining elements
the same.
For instance, let A
Then is a subsequence of A since A
But is not a subsequence of A since it cannot be obtained by
removing elements from A
A consecutive subsequence of some array A is a subsequence of A
of form x x x for some x For instance, and are
consecutive subsequences of A but is not because is not the
next natural number after
Given an integer array A of size N with Ai in N design a dynamic
programming algorithm to find out the maximum length of consecutive
subsequence of A Notice that A might contain duplicated number, eg
A
a Define in plain English subproblems to be solved.
b Write a recurrence relation for the subproblems.
c Using the recurrence formula in part b write an iterative pseudo
code to find the solution. Make sure you specify base cases.
d What is the complexity of your solution?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
