Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void PerformInsertionSort(MyDataList list)
- {
- MyDataList.MyLinkedListNode previous = null;
- for (MyDataList.MyLinkedListNode current = list.head; current != null; current = current.nextNode)
- {
- if (current.data < list.Head())
- {
- previous.nextNode = current.nextNode;
- current.nextNode = list.head;
- list.head = current;
- current = previous;
- }
- else
- {
- for (MyDataList.MyLinkedListNode comparator = list.head; comparator != current && comparator.nextNode != current; comparator = comparator.nextNode)
- {
- if (current.data >= comparator.data && current.data <= comparator.nextNode.data)
- {
- previous.nextNode = current.nextNode;
- current.nextNode = comparator.nextNode;
- comparator.nextNode = current;
- current = previous;
- break;
- }
- }
- previous = current;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement