Lisäyslajittelu
Lisäyslajittelu, also known as insertion sort, is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. However, insertion sort provides several advantages: it is simple to implement, it is efficient for small data sets, and it is efficient for data sets that are already substantially sorted.
The algorithm iterates through the input array, and for each element, it finds the correct position within
In terms of time complexity, insertion sort has an average and worst-case time complexity of O(n^2), where