This article describes the JavaScript data structure of the double linked list insertion sequencing implementation method. Share to everyone for your reference, specific as follows:
Array storage, insert the sort algorithm, in the worst case, the preceding element needs to be moved backwards so that the insertion point is left empty so that the target element is inserted.
When you switch to a linked list, obviously do not need to do this mass movement, according to each node of the precursor node "pointer", to find the insertion point, directly to the target value from the original list off, and then at the insertion point to break the list into two sections, and then reconnect with the target point.
The results of the operation are as follows:
----Sort before---
9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1 8 9 7 6 5 4 3 2 1 7 8---------------9 6, 5 4
0 5 4 3 2 1 5 6 7 8 9 a 4 3 2 1 4 5 6 7 8 9 3 2 1 3 4 5 6 7 A/A-8-----9 a
4 5 6 7 8 9
--Sort---1 2 3 4 5 6 7 8 9 10
I hope this article will help you with JavaScript programming.