In consideration of modern architectures and memory layout, are linked data structures ever worth it?
It feels like an dynamic array is a lot better in every sense.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-13 2:15
Insert into array is 2 stage operation:
1.find first empty/deleted slot(fileld with NULL values)
2.overwrite it with your value
the #1 is stored for convenience as extra variable describing where to get storage without searching empty slots each time.
the #2 is O(1) operation
=======================
Search for some value is not often needed: i usually prefer to store such "key values" in their own variables.
In case you need fast search:
1.sort the array. Should be pre-sorted if you want maximum speed.
2.binary search the array. O(Log N) at worst case O(1) at best