Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Linked vs Dynamic Array

Name: Anonymous 2011-12-12 20:01

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 !!mJCwdV5J0Xy2A21 2011-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

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List