Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6762311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:18:20+00:00 2026-05-26T14:18:20+00:00

What algorithm yields the best distribution when it comes to mapping hash key –>

  • 0

What algorithm yields the best distribution when it comes to mapping hash key --> bucket instance ?

In other words, let’s say I have an hashing function (probably SHA-1) and I have n buckets; what algorithm do I use to map a key to a bucket? E.g. lower bits, upper bits, something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:18:21+00:00Added an answer on May 26, 2026 at 2:18 pm

    Usually, you just mod your hash value with the number of buckets. In the unlikely event that the number of buckets is a power of two, you can use bitwise-and instead.

    An excerpt from Wikipedia on hash function:

    A common solution is to compute a fixed hash function with a very
    large range (say, 0 to 232 − 1), divide the result by n, and use the
    division’s remainder. If n is itself a power of 2, this can be done by
    bit masking and bit shifting. When this approach is used, the hash
    function must be chosen so that the result has fairly uniform
    distribution between 0 and n−1, for any n that may occur in the
    application. Depending on the function, the remainder may be uniform
    only for certain n, e.g. odd or prime numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The question is: Consider the directed graph with 5 vertices. Let the Dijkstra’s algorithm
I'm looking for a string similarity algorithm that yields better results on variable length
Is there an algorithm that given two strings yields the degree of equality between
Is there an algorithm that will yield the same hash for two numbers, no
Context Say, we want to use the Box-Muller algorithm. Starting from a couple of
Algorithm to generate all possible letter combinations of given string down to 2 letters
What algorithm taught you the most about programming or a specific language feature? We
Which algorithm does the JavaScript Array#sort() function use? I understand that it can take
Which algorithm would you use to search short substrings in short texts? By short
What algorithm to use to calculate a check digit for a list of digits?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.