book handy the bubble sort is so simple you can write it from memory even soit' practical only if the amount of data is small (for discussion of what "smallmeanssee "when to use what "the selection sort minimizes the number of swapsbut the number of comparisons is still high it might be useful when the amount of data is small and swapping data items is very time-consuming compared with comparing them the insertion sort is the most versatile of the three and is the best bet in most situationsassuming the amount of data is small or the data is almost sorted for larger amounts of dataquicksort is generally considered the fastest approachwe'll examine quicksort in we've compared the sorting algorithms in terms of speed another consideration for any algorithm is how much memory space it needs all three of the algorithms in this carry out their sort in placemeaning thatbeside the initial arrayvery little extra memory is required all the sorts require an extra variable to store an item temporarily while it' being swapped you can recompile the example programssuch as bubblesort javato sort larger amounts of data by timing them for larger sortsyou can get an idea of the differences between them and how long it takes to sort different amounts of data on your particular system summary the sorting algorithms in this all assume an array as data storage structure sorting involves comparing the keys of data items in the array and moving the items (actually references to the itemsaround until they're in sorted order all the algorithms in this execute in ( time neverthelesssome can be substantially faster than others an invariant is condition that remains unchanged while an algorithm runs the bubble sort is the least efficientbut the simplestsort the insertion sort is the most commonly used of the ( sorts described in this sort is stable if the order of elements with the same key is retained none of the sorts inthis require more than single temporary variable in addition to the original array part ii list stacks and queues linked lists