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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:55:28+00:00 2026-05-29T09:55:28+00:00

Why do I keep seeing different runtime complexities for these functions on a hash

  • 0

Why do I keep seeing different runtime complexities for these functions on a hash table?

On wiki, search and delete are O(n) (I thought the point of hash tables was to have constant lookup so what’s the point if search is O(n)).

In some course notes from a while ago, I see a wide range of complexities depending on certain details including one with all O(1). Why would any other implementation be used if I can get all O(1)?

If I’m using standard hash tables in a language like C++ or Java, what can I expect the time complexity to be?

  • 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-29T09:55:29+00:00Added an answer on May 29, 2026 at 9:55 am

    Hash tables are O(1) average and amortized case complexity, however it suffers from O(n) worst case time complexity. [And I think this is where your confusion is]

    Hash tables suffer from O(n) worst time complexity due to two reasons:

    1. If too many elements were hashed into the same key: looking inside this key may take O(n) time.
    2. Once a hash table has passed its load balance – it has to rehash [create a new bigger table, and re-insert each element to the table].

    However, it is said to be O(1) average and amortized case because:

    1. It is very rare that many items will be hashed to the same key [if you chose a good hash function and you don’t have too big load balance.
    2. The rehash operation, which is O(n), can at most happen after n/2 ops, which are all assumed O(1): Thus when you sum the average time per op, you get : (n*O(1) + O(n)) / n) = O(1)

    Note because of the rehashing issue – a realtime applications and applications that need low latency – should not use a hash table as their data structure.

    EDIT: Annother issue with hash tables: cache

    Another issue where you might see a performance loss in large hash tables is due to cache performance. Hash Tables suffer from bad cache performance, and thus for large collection – the access time might take longer, since you need to reload the relevant part of the table from the memory back into the cache.

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

Sidebar

Related Questions

I am trying to learn jQuery. I keep seeing people using different methods of
I keep seeing that in order to get transformations around the center point of
I keep seeing the phrase duck typing bandied about, and even ran across a
I keep seeing code that does checks like this if (IsGood == false) {
I keep seeing people say that exceptions are slow, but I never see any
I keep seeing what appears to be a memory leak - but I can't
I keep seeing documentation saying that its not possible to send to a remote
I'm trying to learn about this feature of javascript I keep seeing in code,
I am trying to get up to speed with Irony . I keep seeing
Reading some piece of code and I keep seeing this : public override bool

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.