Abstract
Cook's construction from 1971 [4] shows that any two-way deterministic pushdown automaton (2DPDA) can be simulated in time O(n), where n is the length of its input string, and the more general [5] describes analogous results for other abstract machines. The goal of this paper is to make Cook's result usable for a broader spectrum of practical problems.
We introduce a family of one-stack programs that includes 2DPDAs, and present a uniform way to compile any imperative stack program into a new and often faster version by using memoization. The method only explores the computational configurations that are reachable on the current input, in contrast to Cook's method, and builds programs that run in linear time if the original was a 2DPDA in program form. The transformation applies to algorithms not previously dealt with by Cook's method, e.g. fast computation of functions such as Fibonacci and (skn/m).
Preview
Unable to display preview. Download preview PDF.
References
Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman, The Design and Analysis of Computer Algorithms, Addison-Wesley Publishing Company 1974.
Torben Amtoft Hansen, Thomas Nikolajsen, Jesper Larsson Träff, and Neil D. Jones, Experiments with Implementation of two Theoretical Constructions, p. 119–133 in Logic at Botik, Lecture Notes in Computer Science Vol. 363, Springer-Verlag 1989.
Richard S. Bird, Improving Programs by the Introduction of Recursion, Communications of the ACM Vol. 20 No. 11 (November 1977) 856–863.
Stephen A. Cook, Linear-Time Simulation of Deterministic Two-Way Pushdown Automata, p. 75–80 in C.V. Freiman (editor): Information Processing 71, North-Holland Publishing Company 1972.
Stephen A. Cook, Characterization of Pushdown Machines in Terms of Time-Bounded Computers, Journal of the ACM Vol. 18 No. 1 (January 1971) 4–18.
Robert W Floyd, Nondeterministic Algorithms, Journal of the ACM Vol. 14 No. 4 (October 1967) 636–644.
Neil D. Jones, A Note on Linear Time Simulation of Deterministic Two-Way Push-down Automata, Information Processing Letters Vol. 6 No. 4 (1977) 110–112.
Neil D. Jones, Carsten Krogh Gomard, Peter Sestoft: Partial Evaluation and Automatic Program Generation, Prentice Hall International, 1993.
Torben Ægidius Mogensen: Personal communication, September 1993.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1994 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Andersen, N., Jones, N.D. (1994). Generalizing Cook's transformation to imperative stack programs. In: Karhumäki, J., Maurer, H., Rozenberg, G. (eds) Results and Trends in Theoretical Computer Science. Lecture Notes in Computer Science, vol 812. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-58131-6_33
Download citation
DOI: https://doi.org/10.1007/3-540-58131-6_33
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-58131-4
Online ISBN: 978-3-540-48445-5
eBook Packages: Springer Book Archive