Linked Lists - Insert Sort
Description:
Linked Lists - Insert Sort
Write an InsertSort() function which rearranges nodes in a linked list so they are sorted in increasing order. You can use the SortedInsert() function that you created in the "Linked Lists - Sorted Insert" kata below. The InsertSort() function takes the head of a linked list as an argument and must return the head of the linked list.
var list = 4 -> 3 -> 1 -> 2 -> null
insertSort(list) === 1 -> 2 -> 3 -> 4 -> null
If the passed in head node is null or a single node, return null or the single node, respectively. You can assume that the head node will always be either null, a single node, or a linked list consisting of multiple nodes.
The push(), buildOneTwoThree(), and sortedInsert() functions need not be redefined.
Related Kata in order of expected completion (increasing difficulty):
Linked Lists - Push & BuildOneTwoThree
Linked Lists - Length & Count
Linked Lists - Get Nth Node
Linked Lists - Insert Nth Node
Linked Lists - Sorted Insert
Linked Lists - Insert Sort
Linked Lists - Append
Linked Lists - Remove Duplicates
Linked Lists - Move Node
Linked Lists - Move Node In-place
Linked Lists - Alternating Split
Linked Lists - Front Back Split
Linked Lists - Shuffle Merge
Linked Lists - Sorted Merge
Linked Lists - Merge Sort
Linked Lists - Sorted Intersect
Linked Lists - Iterative Reverse
Linked Lists - Recursive Reverse
Inspired by Stanford Professor Nick Parlante's excellent Linked List teachings.
Similar Kata:
Stats:
Created | Aug 16, 2015 |
Published | Aug 17, 2015 |
Warriors Trained | 2331 |
Total Skips | 292 |
Total Code Submissions | 3613 |
Total Times Completed | 1189 |
JavaScript Completions | 539 |
Python Completions | 563 |
Swift Completions | 120 |
Total Stars | 48 |
% of votes with a positive feedback rating | 91% of 243 |
Total "Very Satisfied" Votes | 205 |
Total "Somewhat Satisfied" Votes | 32 |
Total "Not Satisfied" Votes | 6 |