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

  • Home
  • SEARCH
  • 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 4019062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:03:34+00:00 2026-05-20T10:03:34+00:00

I am looking for an associative collection that supports both retrieval and insertion of

  • 0

I am looking for an associative collection that supports both retrieval and insertion of values by key (deletion not important) in at least O(Log(N)) time, and that has a very low memory overhead both in terms of code size and run-time memory consumption.

I am doing this for a small embedded application written in C, so I am trying to minimize the amount of code required, and the amount of memory consumed.

The Google sparse hash data structure would be a possibility if it wasn’t written in C++, and was simpler.

Most hash table implementations that I am aware of use a fair amount of extra space, requiring at least twice as much space as the total number of key-values, or else requiring extra pointers per entry (e.g. bucket chaining hash algorithms). In my structure, key value pairs are just two pointers.

Currently I am using an array of key/value pairs which is sorted, but the insertion is O(N). I can’t help but think there must be a clever way to improve the amortized running time of insertion, for example by doing the insertions in groups, but I am not having any success.

I think that this must be a relatively well-known problem in certain circles, so to make this not too subjective, I’m wondering what the most common solution to the problem stated above is?

[EDIT:]

Some additional information that could be relevant:

  • Keys are integers
  • Number of values could be tiny anywhere from 1 to 2^32.
  • Usage patterns are unpredicatable.
  • I am hoping to keep memory consumption as low as possible (e.g. doubling the size of memory required, would not be ideal)
  • 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-20T10:03:35+00:00Added an answer on May 20, 2026 at 10:03 am

    You could use a hash table that doesn’t use chaining, such as a linear probing or cuckoo hashing scheme. The backing implementation is just an array, and with a load factor of around 0.5, the overhead won’t be too bad, and the implementation complexity (at least for linear or quadratic probing) isn’t too much.

    If you want a good implementation of a binary search tree that has excellent guarantees on performance and isn’t too hard to code up, consider looking into splay trees. They guarantee amortized O(lg n) lookups, and require just two pointers per node. The balance step is also substantially easier than most balanced BSTs.

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

Sidebar

Related Questions

I'm looking for a C library that provides generic collection data structures such as
I'm looking for an elegant way to override values in an associative array. For
I'm looking for a built-in method that combines two associative arrays or objects into
I'm looking for a way to describe an associative object the declarative way. Beyond
Let's say that I'm looking for a specific item in a has_many association. Is
I'm looking for the tool that can build class diagram form the code and
I'm looking for a C++ associative map container type which I can perform multiple
I am looking to create a JavaScript object (associative array) with alphabets as keys.
In PHP, say that you have an associative array like this: $pets = array(
I know that SOCKS 5 supports UDP and I have been over the structure

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.