Skip to content

Instantly share code, notes, and snippets.

@onemouth
Created July 18, 2019 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onemouth/7532884112aae7b1401802d6d753c87c to your computer and use it in GitHub Desktop.
Save onemouth/7532884112aae7b1401802d6d753c87c to your computer and use it in GitHub Desktop.
int ch(int key, int num_buckets) {
random.seed(key);
int b = 0;
for (int j = 1; j < num_buckets; j++) {
if (random.next() < 1.0 / (j + 1))
b = j;
}
return b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment