894 IEEE COMMUNICATIONS LETTERS, VOL. 20, NO. 5, MAY 2016
Balanced Gray Codes With Flexible Lengths
Lu Wang, Zulin Wang, Member, IEEE, Qin Huang, Member, IEEE, and Mu Zhang
Abstract—Robinson and Cohn constructed an (n + 2)-bit
balanced Gray code (BGC) of length 2
n+2
from an n-bit BGC.
This letter extends their construction to flexible lengths by select-
ing a subsequence from transition sequence of an n-bit BGC. For
any target length, we first derive the length range of the desired
subsequence and the occurrence of each bit position in this subse-
quence. Then, an (n + 2)-bit balanced Gray code of flexible length
can be constructed by selecting a subsequence under the two above
constraints.
Index Terms—Balanced Gray codes, transition sequence, flexi-
ble lengths.
I. INTRODUCTION
A
GRAY code [1] is a counting sequence in which two
successive codewords differ only i n one bit position. Let
L
n
c
0
, c
1
, c
2
, ··· , c
2
n
−1
be an n-bit Gray code. The code is
called cyclic if only one bit changes between c
0
and c
2
n
−1
.
Define s
k
where 0 ≤ k ≤ 2
n
− 1 as the bit transition posi-
tion, in which the bit changes, between c
k
and c
(k+1) modulo 2
n
.
Without loss of generality, we assume that c
0
is an all-zero
codeword. The Gray code is then determined by its transi-
tion sequence s
n
, where s
n
s
0
, s
1
, s
2
, ··· , s
2
n
−1
. Moreover,
the number of transitions in bit position i in an n-bit counting
sequence, denoted by TC
n
(i), is called the transition count of
bit position i. The transition count distribution of all bit posi-
tions, i.e.,
(
TC
n
(0), TC
n
(1), ··· , TC
n
(n − 1)
)
, is defined as
the transition count spectrum of the counting sequence.
The most commonly known Gray code is the binary reflected
Gray code (BRGC) proposed by Frank Gray in 1953 to reduce
the error rate in some pulse coded communication systems
[1]. Balanced Gray codes (BGCs) [2] are a subclass of Gray
codes. In general, the distribution of bit transitions for a BGC
is uniform (or almost uniform) among bit positions, i.e., the
difference between every two transition counts is less than
or equal to 2. A 4-bit BRGC and a 4-bit BGC along with
their transition sequences are given in Table I. The transition
count spectrums of the BRGC and the BGC are (8, 4, 2, 2) and
(4, 4, 4, 4), respectively. However, if the transition position is
Manuscript received July 23, 2015; revised November 11, 2015; accepted
November 11, 2015. Date of publication November 17, 2015; date of current
version May 6, 2016. This work was supported in part by the National Natural
Science Foundation of China under Grant 61471022 and Grant 61201156, in
part by the NSAF under Grant U1530117. The associate editor coordinating the
review of this letter and approving it for publication was Z. Ma. (Corresponding
author: Q. Huang.)
L. Wang, Q. Huang, and M. Zhang are with the School of Electronic and
Information Engineering, Beihang University, Beijing 100191, China (e-mail:
wanglu09@buaa.edu.cn; qinhuang@buaa.edu.cn; calering_ococ@163.com).
Z. Wang is with the School of Electronic and Information Engineering,
Beihang University, Beijing 100191, China, and also with the Collaborative
Innovation Center of Geospatial Technology, Wuhan 430079, China (e-mail:
wzulin@buaa.edu.cn).
Digital Object Identifier 10.1109/LCOMM.2015.2501291
TABLE I
A4-B
IT BRGC, A 4-BIT BGC AND THEIR TRANSITION SEQUENCES
ignored between the last and the first codeword, the spectrum
changes to (8, 4, 2, 1) for BRGC and (4, 4, 4, 3) for BGC.
BGCs have been used in many applications, such as
phase change memory (PCM) [3], M-ary phase shift keying
(PSK) [4], and DNA computing [5]. Robinson-Cohn construc-
tion [2] is a well-known method to construct binary BGCs,
which derives (n + 2)-bit BGCs from n-bit BGCs. Suparta and
Zanten developed a general version of Robinson-Cohn con-
struction in [6] and described the results in algebraic form. Bose
and Broeg [7], [8] introduced Lee distance into Gray codes.
Later, Flahive and Bose [9] constructed binary and non-binary
(R-ary) BGCs based on partition-blocks over Lee distance. For
example, when R = 4, binary BGCs can be designed with the
mapping 0 – 00, 1 – 01, 2 – 11, 3 – 10.
However, the existing BGC construction methods only pro-
duce codes with fixed length, e.g., 2
n
for an n-bit binary BGC
and R
n
for an n-bit R-ary BGC. Therefore, in order to obtain
binary BGCs of flexible lengths, we propose a generalized
Robinson-Cohn construction by selecting certain subsequences
from the transition sequence of an n-bit BGC. First, the length
range of the desired subsequence according to the target BGC
is computed. Then, the occurrence of each bit position in the
desired subsequences is derived. Given the length and bit posi-
tion occurrence, a subsequence to construct an (n + 2)-bit BGC
of desired length can be chosen. In some cases, the difference
between every two transition counts can be even less than or
equal to 1.
II. BGC
S WITH FIXED LENGTHS
In this section, we will briefly introduce the algebraic form
of Robinson-Cohn construction [6].
Consider an n-bit cyclic Gray code L
n
whose transition
count spectrum is ( TC
n
(0), TC
n
(1), ··· , TC
n
(n − 1)).Let
1558-2558 © 2015 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.
See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.