I am looking to put together a flowchart for determining which data structures are appropriate for a given problem. The list of data structures are : array, linked list (single/double), hash (maps, etc), trees (binary, N-way), and skip list.
The criteria for choosing a list (from my point of view) are: 1) bounded or unbounded 2) random or sequential access 3) main 开发者_如何学Coperation (read, write, insert, delete) 4) performance 5) ease of coding
For example, if I know an exact number of items, then generally I will use an array. They are easy to search (though not necessarily fast) and easy to maintain.
With large amounts of data, I prefer to go with a tree for the traversal times.
I would be interested in finding out others flowcharts for choosing data structures.
There are tons of different scenarios to consider. This is a tough question because it can be interpreted in terms of complexity or the functionality of certain data structures. For example, if you have a program where sorting is an issue, a BTree would be nice since one could use BSearch on the tree. But one could also perform BSearch on a sorted array. There is a dichotomy to consider for all data structures. It's hard to consider all of the factors since there are theoretically infinite ways the data structures could be used. It is definitely a case by case basis and coming up with a general flow chart may not be a good idea, but that's just me.
精彩评论