c - how to write order preserving minimal perfect hash for integer keys? -


I've searched stackoverflow and google and I do not know what this is:

I Byte is a set of unsigned integer keys, one million or more, I need to use the table as an index. I will be the easiest to use keys as an array index, but I have a 4gb array Do not want to go when im just going to use some couple of entries Be received! Table entries and keys are sequential so I need a hash function that keeps the order safe.

For example key = {56, 69, 3493, 49 9 56, 345678, 345679, .... etc}

{0, 1, 2, 3, 4, 5, .... etc}

The key can be potentially integer, but no more than 2 million in total May be. The number will be different as keys (and related array entries), but the new key always holds a higher number than the previous highest number of keys.

In the above example, if the key 69 was removed, then the hash integer hashing returned to 3493 should be 1 (instead of 2) because it becomes the second lowest number again.

I hope that I am right to explain this. Is it possible to have any fast efficient hashing solution above? I need translation that I take at least 100 SDSs, although hoping to be removed will take me much longer. I looked at CMPH but could not get any usage examples, which was not included in receiving data from a file, it needs to be run under Linux and compiled with GCC using pure C.

Actually, I do not know if I think what you really want to do

It seems that you are trying to get an index number in the "array" (or "list") of sequential commands, which you have stored anywhere.

If you have stored these integer values ​​in an array, then the algorithm that completes the index in optimum time Binary Search

Since your list is known in sequence, then binary search o (log (n)) works in time, which is very fast

If you have an element in the list of "key" , Then the binary search algorithm works anyway (without any effort or space) The task of extracting one element in the Prachi applies to you, naturally, to move all the elements on the right side of the deleted element)

You only have to provide three data to the nanari search algorithm : Array, Array size and desired key, Of course.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -