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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:27:14+00:00 2026-05-15T16:27:14+00:00

Usually (as in C++), the hash function returns any size_t value — thus many

  • 0

Usually (as in C++), the hash function returns any size_t value — thus many different hash values are possible (2^32).

That is why I always thought that when people talked about them being implemented as tables, that is not really true in practice because the table would be much too big (2^32 entries). Of course my assumption was wrong that the table must be as big as the full range of hash values.

It seems that the actual implementation is more difficult than I thought. What I always had in mind, what would be the naive implementation, is something like:

typedef list< pair<Key,Value> > Bucket;
typedef map< size_t, Bucket > Hashtable;

Now my question: How does this naive implementation differs from actual implementations in the praxis in terms of complexity (runtime and memory)?

  • 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-15T16:27:14+00:00Added an answer on May 15, 2026 at 4:27 pm

    Note that there are other ways to implement hash tables as Matthieu M points out. The remainder of this answer assumes that you want to use hashing with buckets made of some kind of list.

    Assuming you are talking about time complexity.

    Hash tables are expected to have O(1) best-case access. Your proposal for implementation in the question uses a map<size_t,Bucket> for access to the buckets which would result in O(log n) time complexity. You need something with O(1) access time complexity, such as a vector<Bucket> to comply with the expected time complexity of a hash table.

    More details

    Hash tables can vary between having excellent and poor time complexity, depending on how sparsely populated they are.

    In the best case, each bucket has at most one entry, and access by key is O(1). This is the commonly quoted complexity for hash tables.

    In the worst case, each key has the same hash value, and access by key is effectively searching a list which results in O(n) behaviour.

    Real-world use is usually somewhere between these extremes, hopefully closer towards O(1).

    The accepted answer to your other question has some simplified code you can use to work through these two extremes to satisfy yourself that this is the case.

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

Sidebar

Related Questions

I understand that salts make the same password hash to different values. However, salts
Supposing simple uniform hashing, that being, any given value is equally like to hash
I have script that gets some data using DBI's fetchall_hashref(). Usually it returns a
Usually (if not always), when jQuery allows you to add a callback to some
Usually when I need to find the max value of an array I use
There are many discussions about security risk for saving hash password in cookies, as
I want to have a dictionary that assigns a value to a set of
Delphi 2009 added the GetHashCode function to TObject. GetHashCode returns an Integer which is
I have a form which usually has a hash. I can submit the form
I usually hang out in a community that uses a bulletin board software. I

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.