ArticleslgStudy

computer science

Bit-reversal permutation

Bit-reversal permutation is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bit-reversal permutation rather than just read about it. In short: In applied mathematics, a bit-reversal permutation is a permutation of a sequence of n items, where n=2k is a power of two. It is defined by indexing the elements of the sequence by the numbers from 0 to n−1, representing each of these numbers by its binary representation (padded to have length exactly k), and mapping each item to the item whose representation has the same bits in the reversed order.

Bit-reversal permutation — main illustration
Bit-reversal permutation — illustration

Key takeaways

  • Bit-reversal permutation belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bit-reversal permutation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bit-reversal permutation from memory before moving on to harder problems.

Reference excerpt

In applied mathematics, a bit-reversal permutation is a permutation of a sequence of n items, where n=2k is a power of two. It is defined by indexing the elements of the sequence by the numbers from 0 to n−1, representing each of these numbers by its binary representation (padded to have length exactly k), and mapping each item to the item whose representation has the same bits in the reversed order. Repeating the same permutation twice returns to the original ordering on the items, so the bit reversal permutation is an involution. This permutation can be applied to any sequence in linear time while performing only simple index calculations. It has applications in the generation of low-discrepancy sequences and in the evaluation of fast Fourier transforms.

Example Consider the sequence of eight letters abcdefgh. Their indexes are the binary numbers 000, 001, 010, 011, 100, 101, 110, and 111, which when reversed become 000, 100, 010, 110, 001, 101, 011, and 111. Thus, the letter a in position 000 is mapped to the same position (000), the letter b in position 001 is mapped to the fifth position (the one numbered 100), etc., giving the new sequence aecgbfdh. Repeating the same permutation on this new sequence returns to the starting sequence. Writing the index numbers in decimal (but, as above, starting with position 0 rather than the more conventional start of 1 for a permutation), the bit-reversal permutations on n=2k items, for k=0,1,2,3,…, are:

Each permutation in this sequence can be generated by concatenating two sequences of numbers: the previous permutation, with its values doubled, and the same sequence with each value increased by one. Thus, for example doubling the length-4 permutation 0 2 1 3 gives 0 4 2 6, adding one gives 1 5 3 7, and concatenating these two sequences gives the length-8 permutation 0 4 2 6 1 5 3 7.

Generalizations The generalization to radix b representations, for b>2, and to n=bk, is a digit-reversal permutation, in which the base-b digits of the index of each element are reversed to obtain the permuted index. The same idea can also been generalized to mixed radix number systems. In such cases, the digit-reversal permutation should simultaneously reverse the digits of each item and the bases of the number system, so that each reversed digit remains within the range defined by its base. Permutations that generalize the bit-reversal permutation by reversing contiguous blocks of bits within the binary representations of their indices can be used to interleave two equal-length sequences of data in-place. There are two extensions of the bit-reversal permutation to sequences of arbitrary length. These extensions coincide with bit-reversal for sequences whose length is a power of 2, and their purpose is to separate adjacent items in a sequence for the efficient operation of the Kaczmarz algorithm. The first of these extensions, called efficient ordering, operates on composite numbers, and it is based on decomposing the number into its prime components. The second extension, called EBR (extended bit-reversal), is similar in spirit to bit-reversal. Given an array of size n, EBR fills the array with a permutation of the numbers in the range 0…n−1 in linear time. Successive numbers are separated in the permutation by at least ⌊n/4⌋ positions.

Applications Bit reversal is most important for radix-2 Cooley–Tukey FFT algorithms, where the recursive stages of the algorithm, operating in-place, imply a bit reversal of the inputs or outputs. Similarly, mixed-radix digit reversals arise in mixed-radix Cooley–Tukey FFTs. The bit reversal permutation has also been used to devise lower bounds in distributed computation. The Van der Corput sequence, a low-discrepancy sequence of numbers in the unit interval, is formed by reinterpreting the indexes of the bit-reversal permutation as the fixed-point binary representations of dyadic rational numbers. Bit-reversal permutations are often used in finding lower bounds on dynamic data structures. For example, subject to certain assumptions, the cost of looking up the integers between 0 and n−1, inclusive, in any binary search tree holding those values, is Ω(nlog⁡n) when those numbers are queried in bit-reversed order. This bound applies even to trees like splay trees that are allowed to rearrange their nodes between accesses.

Algorithms Mainly because of the importance of fast Fourier transform algorithms, numerous efficient algorithms for applying a bit-reversal permutation to a sequence have been devised. Because the bit-reversal permutation is an involution, it may be performed easily in place (without copying the data into another array) by swapping pairs of elements. In the random-access machine commonly used in algorithm analysis, a simple algorithm that scans the indexes in input order and swaps whenever the scan encounters an index whose reversal is a larger number would perform a linear number of data moves. However, computing the reversal of each index may take a non-constant number of steps. Alternative algorithms can perform a bit reversal permutation in linear time while using only simple index calculations. Because bit-reversal permutations may be repeated multiple times as part of a calculation, it may be helpful to separate out the steps of the algorithm that calculate index data used to represent the permutation (for instance, by using the doubling and concatenation method) from the steps that use the results of this calculation to permute the data (for instance, by scanning the data indexes in order and performing a swap whenever the swapped location is greater than the current index, or by using more sophisticated vector scatter–gather operations). Another consideration that is even more important for the performance of these algorithms is the effect of the memory hierarchy on running time. Because of this effect, more sophisticated algorithms that consider the block structure of memory can be faster than this naive scan. An alternative to these techniques is special computer hardware that allows memory to be accessed both in normal and in bit-reversed order. Significant attention has been given to improving the performance of bit-reversal operations within the field of high-performance computing. Developing architecture-aware algorithms is crucial for enabling optimal use of hardware and system software resources such as caches, TLBs, and multicore processors.

References

Illustrations

Bit-reversal permutation: A Hammersley set whose coordinates are the integers from 0 to 255 and their bit-reversals
A Hammersley set whose coordinates are the integers from 0 to 255 and their bit-reversals

Worked examples

Example 1 — a first encounter with Bit-reversal permutation

Start with the simplest possible case. Write down what Bit-reversal permutation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bit-reversal permutation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bit-reversal permutation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bit-reversal permutation

In research
Bit-reversal permutation appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bit-reversal permutation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bit-reversal permutation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Combinatorial algorithms, Fast Fourier transforms, Permutations, so understanding it makes those chapters shorter.
In everyday life
Look for Bit-reversal permutation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bit-reversal permutation” →

How to study Bit-reversal permutation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bit-reversal permutation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bit-reversal permutation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bit-reversal permutation in simple terms?

In applied mathematics, a bit-reversal permutation is a permutation of a sequence of n items, where n=2k is a power of two. It is defined by indexing the elements of the sequence by the numbers from 0 to n−1, representing each of these numbers by its binary representation (padded to have length exa…

Why does Bit-reversal permutation matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bit-reversal permutation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bit-reversal permutation.

Tags

  • Combinatorial algorithms
  • Fast Fourier transforms
  • Permutations

Keep exploring