when to use what use an array or double-ended linked list if insertion speed is not problem the array works when the amount of data to be stored can be predicted in advancethe linked list when the amount of data is unknown if speed is importanta heap is better choice comparison of special-purpose structures table shows the big times for stacksqueuesand priority queues these structures don' support searching or traversal table special-purpose data storage structures data structure insertion deletion comment stack (array or linked listqueue (array or linked listpriority queue (ordered arraypriority queue (heapo( ( ( ( (no( (logno(logndeletes most recently inserted item deletes least recently inserted item deletes highest-priority item deletes highest-priority item sorting as with the choice of data structuresit' worthwhile initially to try slow but simple sortsuch as the insertion sort it may be that the fast processing speeds available in modern computers will allow sorting of your data in reasonable time (as wild guessthe slow sort might be appropriate for fewer than , items insertion sort is also good for almost-sorted filesoperating in about (ntime if not too many items are out of place this is typically the case where few new items are added to an already-sorted file if the insertion sort proves too slowthen the shellsort is the next candidate it' fairly easy to implementand not very temperamental sedgewick estimates it to be useful up to , items only when the shellsort proves too slow should you use one of the more complex but faster sortsmergesortheapsortor quicksort mergesort requires extra memoryheapsort requires heap data structureand both are somewhat slower than quicksortso quicksort is the usual choice when the fastest sorting time is necessary howeverquicksort is suspect if there' danger that the data may not be randomin which case it may deteriorate to ( performance for potentially non-random