#### Date of Award

5-1-2018

#### Document Type

Thesis (Undergraduate)

#### Department or Program

Department of Computer Science

#### First Advisor

Thomas H. Cormen

#### Abstract

The Gray code is a sequence of n consecutive binary numbers arranged so that adjacent numbers in the sequence differ in a single digit and that each number appears in the sequence exactly once. A Gray code is considered cyclic if the first and last numbers in the sequence differ in only one digit position, and those digits have a difference of exactly 1. In this thesis, numbers in a Gray-code sequence may be modular cyclic, meaning that in radix r, two consecutive numbers may vary in a digit with values 0 and r-1. This thesis focuses on methods to generate mixed-radix Gray codes. Mixed-radix representation refers to any k-tupleof radices r = (r_(k-1),r_(k-2),...,r_0). In a mixed-radix representation, each digit position can correspond to a different numerical base. In this thesis, we examine methods to generate two types of cyclic mixed-radix Gray codes: full and dense. Given pi denotes the product of all the radices r_j where j = (0,...,i), a Gray code is considered full if n = p_(k-1) and a Gray code is considered dense if n < p_(k-1). Any full or dense Gray code sequence is a permutation of the sequence <0,1,...,n-1>, with each number appearing exactly once. We give a constant-time algorithm to generate each digit of each number in a cyclic mixed-radix full Gray code for any set of radices r. This thesis also provides a new case in which it is impossible to compute a cyclic mixed-radix dense Gray code. For all r and n for which we do not have proofs that a cyclic Gray code cannot exist and where rk-1 is greater than or equal to 3 or n is even, we show a linear-time method to find a cyclic mixed-radix dense Gray code. When r_(k-1) = 2 and n is odd, we provide a conjecture regarding the possibility of a cyclic mixed-radix dense Gray code for a mixed-radix tuple r.

#### Recommended Citation

Kumar, Devina, "Full and Dense Cyclic Gray codes in Mixed Radices" (2018). *Dartmouth College Undergraduate Theses*. 132.

https://digitalcommons.dartmouth.edu/senior_theses/132

## Comments

Originally posted in the Dartmouth College Computer Science Technical Report Series, number TR2018-851.