Perfect trees and bit-reversal permutations

One well known algorithm is the Fast Fourier Transform (FFT). An efficient iterative version of the FFT algorithm performs as a first step a bit-reversal permutation of the input list. The bit-reversal permutation swaps elements whose indices have binary representations that are the reverse of each other. Using an amortized approach, this operation can be made to run in linear time on a random-access machine. An intriguing question is whether a linear-time implementation is also feasible on a pointer machine, that is, in a purely functional setting. We show that the answer to this question is in the affirmative. In deriving a solution, we employ several advanced programming language concepts such as nested datatypes, associated fold and unfold operators, rank-2 types and polymorphic recursion.

[1]  Alan Mycroft,et al.  Polymorphic Type Schemes and Recursive Definitions , 1984, Symposium on Programming.

[2]  Lawrence C. Paulson,et al.  ML for the working programmer (2. ed.) , 1996 .

[3]  Richard S. Bird,et al.  Generalised folds for nested datatypes , 1999, Formal Aspects of Computing.

[4]  Anne Kaldewaij,et al.  A Simple, Efficient, and Flexible Implementation of Flexible Arrays , 1995, MPC.

[5]  Richard S. Bird,et al.  FUNCTIONAL PEARL On building trees with minimum height , 1997, Journal of Functional Programming.

[6]  Richard S. Bird,et al.  Nested Datatypes , 1998, MPC.

[7]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[8]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[9]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[10]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[11]  Nancy McCracken,et al.  The Typechecking of Programs with Implicit Type Structure , 1984, Semantics of Data Types.

[12]  Richard S. Bird,et al.  Introduction to functional programming using haskeu , 1998 .

[13]  Richard S. Bird,et al.  FUNCTIONAL PEARL On building trees with minimum height , 1997, Journal of Functional Programming.

[14]  Graham Hutton,et al.  Bananas in space: extending fold and unfold to exponential types , 1995, FPCA '95.

[15]  Richard S. Bird,et al.  Introduction to functional programming , 1988, Prentice Hall International series in computer science.