Loading...
Loading...
0
ops.
0
ops.
0
ops.
0
ops.
0
comp.
0
ms
0
sec
0
ops/ms
0
comp/ms
[1] Sum of Swap, Get, Set and Comparison operations.
[2] Swap operations do not count as neither Get nor Set operations.
Insertion sort is a simple sorting algorithm that organizes elements in an array by repeatedly shifting elements to the right until the correct position for the current element is found. For each element, it compares it with the elements in the sorted sublist and shifts elements that are greater than the current element to the right until the correct position for the current element is found.
Read moreInsertion sort has a time complexity of O(n²) on average, but it has a better performance on small data sets and on lists that are already partially sorted. Because of this characteristic, insertion sort is often used as a simple sorting algorithm in embedded systems and other resource-constrained environments. It's also a good choice for educational purposes and simple cases.
Big O Notation | |||
---|---|---|---|
Time complexity | Space complexity | ||
Worst | Average | Best | Worst |
O(n^2) | Θ(n^2) | Ω(n) | O(1) |
Big O Notation defines the lower, average and upper bounds of an algorithm, where Time complexity determines the amount of operations, and Space complexity the amount of memory that can be used
This site uses cookies to ensure you the best experiences of all.
By continuing, I must assume you're okay with them, however, you can read more about them here.
Continue