Selecting the minimum requires scanning formula_1 elements (taking formula_2 comparisons) and then swapping it into the first position. Finding the next lowest element requires scanning the remaining formula_2 elements and so on. Therefore, the total number of comparisons is  formula_4  By arithmetic progression,  formula_5  which is of complexity formula_6 in terms of number of comparisons. Each of these scans requires one swap for formula_2 elements (the final element is already in place). Among quadratic sorting algorithms (sorting algorithms with a simple average-case of Θ("n"2)), selection sort almost always outperforms bubble sort and gnome sort. Insertion sort is very similar in that after the "k"th iteration, the first "k" elements in the array are in sorted order. Insertion sort's advantage is that it only scans as many elements as it needs in order to place the "k" + 1st element, while selection sort must scan all remaining elements to find the "k" + 1st element. Simple calculation shows that insertion sort will therefore usually perform about half as many comparisons as selection sort, although it can perform just as many or far fewer depending on the order the array was in prior to sorting. It can be seen as an advantage for some real-time applications that selection sort will perform identically regardless of the order of the array, while insertion sort's running time can vary considerably. However, this is more often an advantage for insertion sort in that it runs much more efficiently if the array is already sorted or "close to sorted." While selection sort is preferable to insertion sort in terms of number of writes (Θ("n") swaps versus Ο("n"2) swaps), it almost always far exceeds (and never beats) the number of writes that cycle sort makes, as cycle sort is theoretically optimal in the number of writes. This can be important if writes are significantly more expensive than reads, such as with EEPROM or Flash memory, where every write lessens the lifespan of the memory. Finally, selection sort is greatly outperformed on larger arrays by Θ("n" log "n") divide-and-conquer algorithms such as mergesort. However, insertion sort or selection sort are both typically faster for small arrays (i.e. fewer than 10–20 elements). A useful optimization in practice for the recursive algorithms is to switch to insertion sort or selection sort for "small enough" sublists.