Dynamic programming

Maximal contiguous sum

Given a list of numbers we define a contiguous sum as for some . Design an algorithm which computes the largest contiguous sum.

Longest increasing subsequence

Given a list of numbers design an algorithm which finds the longest sequence such that and for all .

Longest palindrome

A palindrome is a string which reads the same in both directions. For example, "abba" is a palindrome, but "abc" is not. Given a string, how would you find the longest (contiguous) palindrome it contains?

Cheapest triangulation

Consider a convex polygon with vertices . A triangulation of is a collection of diagonals such that no two intersect in the interior of . Such an arrangement always breaks down into triangles.

Suppose the cost of a triangulation is defined as the sum of the lengths of all diagonals. How would you find the cheapest triangulation of ?

Matrix multiplication

Given two matrices and of size and respectively, it takes operations to compute the product . Suppose we have one more matrix of size . We can compute the product in one of two ways: Which one is better? How would you approach the problem if you had to compute the product of matrices?

Imagine a city whose streets form a perfect grid. Your task is to walk from position to by only going in the positive - and -directions. Each intersection is controlled by a local mafioso who charges a fee for anyone walking through. How would you find the cheapest route assuming that you have information about the prices at all intersections? How would you approach the problem if you are allowed to walk in all four directions?