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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:46:55+00:00 2026-05-30T00:46:55+00:00

From the doc of Java about Hashtable class, it says As a general rule,

  • 0

From the doc of Java about Hashtable class, it says

As a general rule, the default load factor (.75) offers a good tradeoff between time and space costs

So the load factor for Hashtable is 0.75, which means if there are N keys, Hashtable will use M = N/0.75 spaces to store them.

In CLRS book, it also introduces load factor alpha.

But from my understanding, CLRS intends to set alpha larger than 1, i.e., M = N/alpha < N. This means a Hashtable can use M slots where M < N so that it can save storage from unused keys.

I say M < N can save storage because normally we don’t know exactly value for N, but we know the set of the keys and use N to stand for possible number of keys. The set of the keys may be very big, but the number of actual keys in use is very small. So setting M smaller than N can save the storage. Also this is why normally Hashtable does not use a direct array to map every {key, value} 1:1.

But Hashtable in Java use storage more than N. I think it is not consistent with the CLRS design, right?

Am I right?

thanks

  • 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-30T00:46:57+00:00Added an answer on May 30, 2026 at 12:46 am

    Well, the load factor should be larger than the elements added. Division by a number less than one results in a larger number than the initial one.

    Assuming you want to add 100 elements you can write either:

    AllocationSize = 100 / 0.75; // Your formula: M = N/0.75 
    

    or

    AllocationSize = 100 * 1.33333333; // M = N / X -> M = N * (1/X)
    

    where both results in 133.333333 -> 133.

    The whole JavaDoc:

    An instance of Hashtable has two parameters that affect its
    performance: initial capacity and load factor. The capacity is the
    number of buckets in the hash table, and the initial capacity is
    simply the capacity at the time the hash table is created. Note that
    the hash table is open: in the case of a “hash collision”, a single
    bucket stores multiple entries, which must be searched sequentially.
    The load factor is a measure of how full the hash table is allowed to
    get before its capacity is automatically increased. When the number of
    entries in the hashtable exceeds the product of the load factor and
    the current capacity, the capacity is increased by calling the rehash
    method.

    Generally, the default load factor (.75) offers a good tradeoff
    between time and space costs. Higher values decrease the space
    overhead but increase the time cost to look up an entry (which is
    reflected in most Hashtable operations, including get and put).

    The initial capacity controls a tradeoff between wasted space and the
    need for rehash operations, which are time-consuming. No rehash
    operations will ever occur if the initial capacity is greater than the
    maximum number of entries the Hashtable will contain divided by its
    load factor. However, setting the initial capacity too high can waste
    space.

    If many entries are to be made into a Hashtable, creating it with a
    sufficiently large capacity may allow the entries to be inserted more
    efficiently than letting it perform automatic rehashing as needed to
    grow the table.

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

Sidebar

Related Questions

Java doc says - The class Object does not itself implement the interface Cloneable,
From the Java doc: CLASS: Annotations are to be recorded in the class file
in this page of tutorial : http://java.sun.com/javaee/6/docs/tutorial/doc/bnadu.html discuss about hello2 application on samples folder.
From J2me doc we know that: java.lang.InterruptedException Thrown when a thread is waiting, sleeping,
I noticed that in Java(doc) there exists something like @inheritDoc, so that comments from
I am trying to retrieve one node from a xml doc in android(java). <?xml
what is java.lang.UnsupportedClassVersionError ? I read from the doc : Thrown when the Java
The java doc says the append method is thread safe. However, I recall that
I'm having this link statement: List<UserGroup> domains = UserRepository.Instance.UserIsAdminOf(currentUser.User_ID); query = (from doc in
What's the best way to move a document from one doc library to another?

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.