Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> incremental insert vs two pass

Insert each element in its sorted position. It will only degenerate if there are many more inserts than lookups, in which case a hash table would do nothing for you.

This could also be a good case for a radix structure.

> void* hash table

I would stay far from poor implementations of high level languages. Why use C if you want generics?

A reusable hash table can be implemented by implementing open addressing with 64 bit integer keys. Then if you have a fancy type you write a hash function and perform linked list chaining on the values.

Another way is to treat the keys as byte arrays.

> seemed the most intuitive way for the 2nd part.

Intuition is a kind of familiarity. There is no reason to learn C if you just write the techniques you already know in a less safe and more verbose way. You instead should be learning a new way to think about problems.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: