M
M
Mercury132021-08-02 14:37:55
Algorithms
Mercury13, 2021-08-02 14:37:55

How to find a word guaranteed not to be in a set?

There is a certain alphabet - for example, A..Z.
There is a set of words from this alphabet.
Come up with a word from this alphabet that meets two requirements.
1. Not very long.
2. Not included in the set.
What are the considerations?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2021-08-02
@Mercury13

Figured it out, stupidly. Using combinatorics, we calculate how long (according to the Dirichlet principle) our word should be: for example, if we have numbers from 0 to 9 and 125 lines, it is enough to take three-digit ones. Here we take 126 bits (well, or 128 for a round count), from our numbers we take only three-digit ones and start filling in the bits. There is, for example, 025 - here in the 25th bit we put one. After that, it remains to find zero in the bit mask and convert it to our string: in the 45th place, it means 045.

H
hint000, 2021-08-02
@hint000

https://en.wikipedia.org/wiki/Bloom_Filter

is a probabilistic data structure invented by Burton Bloom in 1970 that allows you to check whether an element belongs to a set. In this case, it is possible to get a false positive (there is no element in the set, but the data structure reports that it is), but not a false negative.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question