Insert sorting in the case of Array StorageAlgorithmIn the worst case, the previous elements need to be constantly moved to the backend so as to leave a blank space at the insertion point so that the target element can be inserted.
When you replace it with a linked list, you obviously do not need to do this kind of movement. Based on the "Pointer" of each node's precursor node, locate the insertion point and directly remove the target value from the original linked list, then, break the Linked List into two parts at the insertion point, and then re-connect it with the target point.
<! Doctype HTML>
-- Before sorting ---
10 9 8 7 6 5 4 3 2 1
9 10 8 7 6 5 4 3 2 1
8 9 10
7 6 5 4 3 2 1
7 8 9 10 6 5 4 3 2 1
6 7 8 9 10 5 4 3 2 1
5 6 7 8 9 10 4 3 2 1
4 5 6 7 8 9 10 3 2 1
3 4 5 6 7 8 9 10 2 1
2 3 4 5 6 7 8 9 10 1
1 2 3 4 5 6 7 8 9 10
-- After sorting ---
1 2 3 4 5 6 7 8 9 10