educative.io

How to select k and m for bloom filter

  • How to select k hash function and m bits. So i guess if there is more k hash function then less collision. So how to choose m bits and number of hash function to work this properly. Any guideliance?

Hi @AmSh, thanks for reaching out.

While creating the filter, we must identify the value of k.
First, we must set the range you expect n to be in. After that, we`ll choose a potential m (the number of bits). Given an m and an n, we have a function to evaluate the value k = (m/n)ln(2).

Happy coding :slight_smile: