Generate all sequences of bits within Hamming distance t

后端 未结 4 1532
春和景丽
春和景丽 2020-12-04 03:22

Given a vector of bits v, compute the collection of bits that have Hamming distance 1 with v, then with distance 2, up to an input paramet

4条回答
  •  臣服心动
    2020-12-04 03:47

    First: There is a bijection between hamming dist k bit-vectors and subsets (of n aka v.size()) of kardinality k (the set of indices with changed bits). Hence, I'd enumerate the subsets of changed indices instead. A quick glance at the SO history shows this reference. You'd have to keep track of the correct cardinalitites of course.

    Considering efficiency is probably pointless, since the solution to your problem is exponential anyways.

提交回复
热议问题