Dynamic programming
When going over the lab7b I wanted to understan more clearly how to identity patterns and similarties to other problems and when to use dynamic programming.
A subsequence of a sequence like a and array, a linked list, or a string, is obtained by removing zero or more elements and keeping the rest in the same sequence order. It is also called a substring if the elements are contiguous in the original sequence.
Working on the examples:
- Given an array
of integers, compute the length of a longest increasing subsequence of . A sequence is increasing if for every index .
Algorithm 1 Longest Increasing Subsequence
procedure LIS()
for to do
LIS
end for
for down to do
for down to do
if then
LIS LIS
else
LIS
end if
end for
end for
return LIS
end procedure