What are the main differences, advantages and disadvantages between static and dynamic data structures?
Under which categories do the most common data structures fall?
How could I know in which situation to use each?
To start with an oversimplification:
There are just a few basic kinds of data structures: arrays, lists and trees. Everything else can be composed by using different types of these two structures (e.g. a hash table can be implemented with an array for the hash values and one list for each hash value to handle collisions).
Of these structures, arrays are static (i.e., their memory footprint does not vary over time as operations are performed on them) and everything else is dynamic (i.e., in the general case the memory footprint changes).
The differences between the two kinds of structures can be derived from the above:
There are also other differences, which however only come into play if your data might be sorted. I can't give an extensive list, as there are many dynamic data structures which exhibit different performance characteristics for different operations ("add", "remove", "find") and so they cannot be placed all under the same roof.
A very visible difference is that sorted arrays require moving (possibly a lot of) stuff around in memory for any operation other than "find", while dynamic structures generally perform less work.
So, to recap:
Edit: I did not mention graphs, another kind of dynamic data structure which arguably cannot be composed from simpler parts (by definition, a tree has exactly one link going "into" any node except the root, while graphs may have more than one). However, graphs cannot really be compared with other structures in a "what would be better to use" scenario, because you either need to use a graph or you do not (other structures may exhibit different performance, but in the end they all support the same set of operations).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With