Categories

Linked List Sort

☆☆☆☆☆ No ratings yet

Make a linked list of elements. For each element in your list to be sorted, traverse the linked list until you find the first element that’s bigger than it. Then insert it into that spot in the linked list. Of course, if you’ve gotten to the end of the linked list and no item was bigger than it, then just add it at the end. Then to gather the sorted results, just traverse the linked list. This is basically an insertion sort but much more efficient because you don’t have to shift half the array for each insertion.