Chapter 30 examines an important algorithm called the fast Fourier transform, or FFT. The first step of

Question:

Chapter 30 examines an important algorithm called the fast Fourier transform, or FFT. The first step of the FFT algorithm performs a bit-reversal permutation on an input array A[0 . . n - 1] whose length is n = 2k for some nonnegative integer?k. This permutation swaps elements whose indices have binary representations that are the reverse of each other.

We can express each index?a?as a?k-bit sequence??ak-1, ak-2, . . . , a0?, where?a?=?k-1i=?0 ai 2i. We define revk.??ak-1, ak-2, . . . ,a0?)?=??a0, a1, . . . ,ak-1?;

thus,

image

For example, if?n?=?16?(or, equivalently,?k?=?4), then revk(3)?=?12, since the?4-bit representation of?3?is?0011, which when reversed gives?1100, the?4-bit representation of?12.

a.?Given a function revk that runs in ?(k) time, write an algorithm to perform the bit-reversal permutation on an array of length n = 2k in O(nk)?time.

We can use an algorithm based on an amortized analysis to improve the running time of the bit-reversal permutation. We maintain a "bit-reversed counter" and a procedure BIT-REVERSED-INCREMENT?that, when given a bit-reversed-counter value?a, produces revk?(revk(a) + 1). If k = 4, for example, and the bit-reversed counter starts at 0, then successive calls to BIT-REVERSED-INCREMENT produce the sequence 0000, 1000, 0100, 1100, 0010, 1010, . . . = 0, 8, 4, 12, 2, 10, . . . .

b.?Assume that the words in your computer store?k-bit values and that in unit time, your computer can manipulate the binary values with operations such as shifting left or right by arbitrary amounts, bitwise-AND, bitwise-OR, etc. Describe an implementation of the BIT-REVERSED-INCREMENT?procedure that allows the bit-reversal permutation on an?n-element array to be performed in a total of?O(n)?time.

c. Suppose that you can shift a word left or right by only one bit in unit time. Is it still possible to implement an O(n)-time bit-reversal permutation?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Introduction to Algorithms

ISBN: 978-0262033848

3rd edition

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

Question Posted: