Research and Advances

Improving programs by the introduction of recursion

A new technique of program transformation, called “recursion introduction,” is described and applied to two algorithms which solve pattern matching problems. By using recursion introduction, algorithms which manipulate a stack are first translated into recursive algorithms in which no stack operations occur. These algorithms are then subjected to a second transformation, a method of recursion elimination called “tabulation,” to produce programs with a very efficient running time. In particular, it is shown how the fast linear pattern matching algorithm of Knuth, Morris, and Pratt can be derived in a few steps from a simple nonlinear stack algorithm.

Advertisement

Author Archives

Research and Advances

Notes on recursion elimination

Various methods of recursion elimination are applied to the schematic recursive procedure: proc S(x); px then N(x); S(ƒx); S(gx); M(x) fi. Procedures with this general form arise in connection with tree traversal and sorting algorithms. Each method of recursion removal involves the use of one or more stacks, and the solutions are compared on the basis of their running time.

Shape the Future of Computing

ACM encourages its members to take a direct hand in shaping the future of the association. There are more ways than ever to get involved.

Get Involved