Implementation of Hirschberg's algorithm; linear space implementation of dynamic programming