when to use what structures because they are used to store and retrieve data using key values this works for general-purpose database programs (as opposed to specialized structures such as stackswhich allow access to only certain data itemswhich of these general-purpose data structures is appropriate for given problemfigure shows first approximation to this question howeverthere are many factors besides those shown in the figure for more detailwe'll explore some general considerations first and then zero in on the individual structures small amount of data start no hash table yes searching and insertion must be very fast no binary search tree yes key distribution guaranteed random yes amount of data predictable no linked list yes search speed more yes important than insertion speed ordered array no unordered array no balanced tree figure relationship of general-purpose data structures speed and algorithms the general-purpose data structures can be roughly arranged in terms of speedarrays and linked lists are slowtrees are fairly fastand hash tables are very fast howeverdon' draw the conclusion from figure that it' always best to use the fastest structures there' penalty for using them firstthey are--in varying degrees--more complex to program than the array and linked list alsohash tables require you to know in advance about how much data can be storedand they don' use memory very efficiently ordinary binary trees will revert to slow (noperation for ordered dataand balanced treeswhich avoid this problemare difficult to program