I have an array of elements. The array is sorted by the ID of the elements, but the ID's are non-sequential e.g. there are gaps in the ID numbers.
I use binary search today to find a specific ID.
The ID is 3 bytes, which gives about 16 million possibilities. The number of ID's in a given array is much lower, maybe 10 000.
This is an embedded/plc platform, which means I can't have a 16MB lookup table, that takes too much memory. I've looked at bitsets an such, but I'm not sure if thats the right approach, or how to calculate an array offset from that.
I realize this may be a tough one given that I want to do the good old "speed for memory" trade-off, but I have very little memory, maybe 2MB or less to spare for this. But the hardware is fixed.
Edit: The elements of the array are fixed for a given application, no inserts or deletions of array elements.
How can I build/precompute a lookup table or similar to speed up locating an ID?
Thanks