Java – the difference between static and dynamic data structures

What are the main differences, advantages and disadvantages between static and dynamic data structures?

In which categories does the most common data structure decline?

How do I know when to use it?

Solution

Start oversimplifying:

There are only a few basic types of data structures: arrays, lists, and trees Other can be combined by using these two structures of different types (for example, a hash table can conflict with an array of hash values and a list of each hash value)

In these structures, arrays are static (i.e., their memory footprint does not change over time as they are operated on), and everything else is dynamic (i.e., in general, the memory footprint changes)

The difference between the two structures can be derived from the above:

>Static needs to know the maximum size in advance, while dynamic can adapt > static will not reallocate memory, no matter what, so you can ensure the memory requirements

There are other differences, but if your data may be sorted, it will only work I can't give a broad list because many dynamic data structures show different performance characteristics for different operations ("add", "delete", "find"), so they can't be placed under the same roof

A very obvious difference is that sorted arrays need to move (possibly many) any operation other than "find" in memory, while dynamic structures usually perform less work

So, to sum up:

>If you need the guarantee of maximum memory utilization, you can't select any option except array. > If you have an upper limit on the size of your data, consider using arrays The array can be well applied to the problems that mainly need to add / delete operations (keep the array Unsorted) and mainly need to find operations (keep the array sorted) but do not exist at the same time. > If you do not have a hard upper limit, or if you require that all additions / deletions / lookups be fast, use the appropriate dynamic structure

Edit: I didn't mention graphics. Another type of dynamic data structure can't be composed of simpler parts (by definition, a tree has only one link to any node other than the root, and there may be multiple graphics) However, because you need to use graphics or not (other structures may exhibit different performance, so graphics and other structures cannot actually be compared with other structures because they all support the same set of operations)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>