Longest palidromic subsequence

Longest Palindromic Subsequence is the problem of finding the longest palindromic subsequence of a sequence.

The solution utilizes dynamic programming.

Overview
The problem is usually defined as:

Given a sequence of items, find the length of the longest subsequence which is a palindrome. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, in the string abcdefg, "abc", "abg", "bdf", "aeg" are all subsequences.

Recursive solution
psuedo code:

Dynamic programming
pseudo code: