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

  • SEARCH
  • Home
  • 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 7745097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:55:39+00:00 2026-06-01T09:55:39+00:00

Why the capacity must be a multiple or 2? Why use & in the

  • 0

Why the capacity must be a multiple or 2?
Why use “&” in the indexFor functions?
Why recompute the hash in the hash function instead of directly using the key’s hash code?

I think there are some important differences between the this implementation and the description on the “Introduction to Algorithm”.

What does “>>>” mean?

static int hash(int h) {
        // This function ensures that hashCodes that differ only by
        // constant multiples at each bit position have a bounded
        // number of collisions (approximately 8 at default load factor).
        h ^= (h >>> 20) ^ (h >>> 12);
        return h ^ (h >>> 7) ^ (h >>> 4);
}

Can anyone give me some guide ? I appreciate If some one can explain the hash algorithm.
Thanks a lot!

  • 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-06-01T09:55:41+00:00Added an answer on June 1, 2026 at 9:55 am

    This is a performance optimization. The usual way to map a hash code to a table index is

    table_index = hash_code % table_length;
    

    The % operator is expensive. If table_length is a power of 2, then the calculation:

    table_index = hash_code & (table_length - 1);
    

    is equivalent to the (much) more expensive modulo operation.

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

Sidebar

Related Questions

How do I find out the storage capacity of my harddisk without using the
What product or tool do you use to do Resource Capacity planning for your
Whenever Capacity is 0 - my PHP code seems to return only the phrase
Is there a way to reduce the capacity of a vector ? My code
I have a program with the capacity for multiple users. At the moment the
First some background: VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web
I'm using Visual c++. I'm trying to implement a circular buffer, this CB must
Can I use capacity to find the actual size or length of a ShortBuffer?
Is the capacity size of string always a multiple value of 15? for example:
I was reading the Maximum Capacity Specifications for SQL Server and I came across

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.