An Algorithm for Generating All Subsets in Lexicographic Order

The algorithms for generating all subsets of a given set, like many other generating algorithms, are of two main types: for generating in lexicographic order or in Gray code order. Many of them use binary representation of integers (i.e., binary vectors) as characteristic vectors of the subsets.Here...

Full description

Saved in:
Bibliographic Details
Published in2022 International Conference Automatics and Informatics (ICAI) pp. 271 - 275
Main Author Bakoev, Valentin
Format Conference Proceeding
LanguageEnglish
Published IEEE 06.10.2022
Subjects
Online AccessGet full text
DOI10.1109/ICAI55857.2022.9959993

Cover

More Information
Summary:The algorithms for generating all subsets of a given set, like many other generating algorithms, are of two main types: for generating in lexicographic order or in Gray code order. Many of them use binary representation of integers (i.e., binary vectors) as characteristic vectors of the subsets.Here we consider the set U n of n elements that are ordered according to a given total order relation. We propose the ordering of characteristic vectors and their serial numbers (i.e., their corresponding integers) such that the characteristic vectors define a lexicographic ordering of subsets of U n . To get this, we define and study the properties of three sequences: (1) p n -of all subsets in lexicographic order, (2) c n -of characteristic vectors corresponding to p n , and (3) s n -of integers representing the vectors of c n . We then propose a simple, straightforward, and fast algorithm that, for a given n, 1 ≤ n ≤ 64, generates the sequence s n . This algorithm only performs integer additions. Its time and space complexity is of the type Θ(2 n )-exponential with respect to the size of the input n but linear with respect to the size of the output 2 n . The algorithm was used in the creation of sequence A356120 in the OEIS [1]. Finally, the general case where n is a positive natural number and the generation of the subsets themselves, i.e., the sequence p n , are discussed.
DOI:10.1109/ICAI55857.2022.9959993