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 6958215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:06:40+00:00 2026-05-27T15:06:40+00:00

I read in an article which says : It is a common practice to

  • 0

I read in an article which says:

It is a common practice to recommend a prime number to be the size of a hash table. This way, a funnel will occur only if the keys are multiples of the prime number.

Here, why should a prime number be used for the initial size, and what is funnelling?

  • 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-27T15:06:41+00:00Added an answer on May 27, 2026 at 3:06 pm

    Long answer: here

    Short answer:

    A funnel occurs when 2+ keys get hashed to the same value because of an error with the underlying hashing function. Like this:

    Map<String,Object> myMap = new HashMap<String,Object>();
    Thing thing1, thing2;
    thing1 = new Thing();
    thing2 = new Thing();
    
    myMap.put("ab", thing1);
    myMap.put("ba", thing2);
    

    If there is an inherent flaw in the hashing function used by HashMap<K,V>, a “funnel” could occur where the keys ab and ba both map to, say, thing1.

    Think of a funnel as an actual funnel: multiple inputs get funneled into the same place.

    Edit
    If a hash function is flawed and does contain funnels, then a way to minimize their occurrence is to set the size of the table to being a prime number.

    This is because, in terms of being a “class” (category) of numbers, prime numbers have the least amount of factors. According to that article, funnels occur when a given key is a factor or multiple of the size of the table. So if we set the table size to 100 (not a prime number), we introduce the possibility of funneling when the provided key is any factor of 100: 1, 2, 4, 5, 10, …, 100, 200, 300, etc.

    But if we make the size of the table to a prime, say, 101… then the only possibility of a funnel occurs at: 1, 101, 202, 302, etc. We’ve greatly reduced the possibility of a funnel.

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

Sidebar

Related Questions

I read this article ( archived link ) which explained very well how to
I read an article which explains what prototype chain is. It says that if
I recently read this article . Which uses the Silverlight Bing maps control to
I have read from some article that say's Apple doesn't approve the application which
I read an article entitled Tags First GWT , in which the writer suggests
I read This article and i found it interesting. To sum it up for
I read and article talking about moving beyond 960px width for websites. This width
I read this article where Ayende states NHibernate can (compared to EF 4): Collection
after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess =
I read this article Managing Hierarchical Data in MySQL At the end of this

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.