Contents

A Simple Algorithm for Generating Subsets of \(k\) or Fewer Elements of an \(n\)-Set

R.E. Sabin 1
1Computer Science Department Loyola College Baltimore, MD 21210 USA

Abstract

Forming all distinct subsets with \(k\) or fewer objects from a set with \(n\) elements can be accomplished by generating a subset of the binary reflected Gray code. This paper presents a straightforward algorithm that generates the desired Gray codewords by altering the stack which maintains the transition sequence that determines the next codeword position to be altered.