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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:33:19+00:00 2026-06-01T13:33:19+00:00

Are hashtables always faster than trees? Though Hashtables have O(1) search complexity but suppose

  • 0

Are hashtables always faster than trees? Though Hashtables have O(1) search complexity but suppose if due to badly designed hash function lot of collisions happen and if we handle collisions using chained structure (say a balanced tree) then the worst case running time for search would be O(log n). So can I conclude for big or small data sets even in case of worst case scenarios hash tables will always be faster than trees? Also If I have ample memory and I dont want range searches can I always go for a hash table?

  • 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-01T13:33:21+00:00Added an answer on June 1, 2026 at 1:33 pm

    Are hashtables always faster than trees?

    No, not always. This depends on many things, such as the size of the collection, the hash function, and for some hash table implementations – also the number of delete ops.

    hash-tables are O(1) per op on average – but this is not always the case. They might be O(n) in worst cases.

    Some reasons I can think of at the moment to prefer trees:

    1. Ordering is important. [hash-tables are not maintaining order, BST is sorted by definition]
    2. Latency is an issue – and you cannot suffer the O(n) that might occur. [This might be critical for real-time systems]
    3. Ther data might be “similar” related to your hash function, and many elements hashed to the same locations [collisions] is not unprobable. [this can be sometimes solved by using a different hash function]
    4. For relatively small collections – many times the hidden constant between hashtable’s O(1) is much higher then the tree’s – and using a tree might be faster for small collections.

    However – if the data is huge, latency is not an issue and collisions are unprobable – hash-tables are asymptotically better then using a tree.

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

Sidebar

Related Questions

I have Vector of Hashtables and each hash table has two elements with keys
Hashtables have a syncroot property but generic dictionaries don't. If I have code that
I want to have an ArrayList where it contains HashTables. I create a Hashtable
i have a class which has a string and a hash table.hash table contains
How would I implement an Array of Hashtables in c++? I have a hashtable
I have a question about duplicate Hashtables in Java (maybe duplicate Java Collections). My
Possible Duplicate: What exactly are hashtables? I understand the purpose of using hash functions
I have been recently drilled in a couple of interviews about Hashtables and when
This part of could should return always the same hash value to each Key
Associative arrays are usually implemented with Hashtables. But recently, I came to know that

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.