Skew binary number system

The skew binary number system is a non-standard positional numeral system in which the nth digit contributes a value of times the digit (digits are indexed from 0) instead of times as they do in binary. Each digit has a value of 0, 1, or 2. Notice that a number can have many skew binary representations. For example, a decimal number 15 can be written as 1000, 201 and 122. Each number can be written uniquely in skew binary canonical form where there is only at most one instance of the digit 2, which must be the first non-zero least significant digit. In this case 15 is written canonically as 1000.

Examples

Canonical skew binary representations of the numbers from 0 to 15 are shown in following table:[1]

DecimalSkew binarybinary
000
111
2210
31011
411100
512101
620110
7100111
81011000
91021001
101101010
111111011
121121100
131201101
142001110
1510001111

Arithmetical operations

The advantage of skew binary is that each increment operation can be done with at most one carry operation. This exploits the fact that . Incrementing a skew binary number is done by setting the only two to a zero and incrementing the next digit from zero to one or one to two. When numbers are represented using a form of run-length encoding as linked lists of the non-zero digits, incrementation and decrementation can be performed in constant time.

Other arithmetic operations may be performed by switching between the skew binary representation and the binary representation.[2]

From skew binary representation to binary representation

Given a skew binary number, its value can be computed by a loop, computing the successive values of and adding it once or twice for each such that the th digit is 1 or 2 respectively. A more efficient method is now given, with only bit representation and one subtraction.

The skew binary number of the form without 2 and with 1s is equal to the binary number minus . Let represents the digit repeated times. The skew binary number of the form with 1s is equal to the binary number minus .

From binary representation to skew binary representation

Similarly to the preceding section, the binary number of the form with 1s equals the skew binary number plus . Note that since addition is not defined, adding corresponds to incrementing the number times. However, is bounded by the logarithm of and incrementation takes constant time. Hence transforming a binary number into a skew binary number runs in time linear in the length of the number.

Applications

The skew binary numbers were developed by Eugene Myers in 1983 for a purely functional data structure that allows the operations of the stack abstract data type and also allows efficient indexing into the sequence of stack elements.[3] They were later applied to skew binomial heaps, a variant of binomial heaps that support constant-time worst-case insertion operations.[4]

See also

Notes

  1. Sloane, N. J. A. (ed.). "Sequence A169683". The On-Line Encyclopedia of Integer Sequences. OEIS Foundation.
  2. Elmasry, Amr; Jensen, Claus; Katajainen, Jyrki (2012). "Two Skew-Binary Numeral Systems and One Application" (PDF). Theory of Computing Systems. 50: 185–211. doi:10.1007/s00224-011-9357-0.
  3. Myers, Eugene W. (1983). "An applicative random-access stack". Information Processing Letters. 17 (5): 241–248. doi:10.1016/0020-0190(83)90106-0. MR 0741239.
  4. Brodal, Gerth Stølting; Okasaki, Chris (November 1996). "Optimal purely functional priority queues". Journal of Functional Programming. 6 (6): 839–857. doi:10.1017/s095679680000201x.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.