What kind of data structure would you use to implement a big persistent array like structure (size > 10 Mio elements)
The interface of the data structure should support the following operations:
YType get(IdxType idx) // random access
void insertIdx(IdxType idx, YType yValue) // random insert
void deleteIdx(IdxType idx) // random delete
Let the index IdxType
be a scalar unsigned value such as unsigned long long
and YType
a scalar value or a struct.
The complexity for these operations should never be bigger than O(log n) and it would be very efficient if the complexity for random access would drop to O(1) after a while, since for many use cases read operations will be used most.
These requirements rule out in memory data structures such as vectors or lists, which could be written to disc, since the insert complexity for vectors is O(n) and random access for lists is also O(n).
EDIT:
Please note, that a hash map or tree like data structures with index keys do not fulfill the requirements. The value for a certain index can change. i.e. when inserting a value for an index all the subsequent indexes change their values. This is exactly what happens to subsequent indexes in an array, when inserting an element.