data-structures · beginner · ~15 min
Reduce a wide hash to a table index.
Implement int bucket_of(unsigned long hash, int nbuckets) returning which bucket (0 .. nbuckets-1) a hash falls into.
int bucket_of(unsigned long hash, int nbuckets) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.