Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. public static void PerformInsertionSort(MyDataList list)
  2. {
  3. MyDataList.MyLinkedListNode previous = null;
  4. for (MyDataList.MyLinkedListNode current = list.head; current != null; current = current.nextNode)
  5. {
  6. if (current.data < list.Head())
  7. {
  8. previous.nextNode = current.nextNode;
  9. current.nextNode = list.head;
  10. list.head = current;
  11. current = previous;
  12. }
  13. else
  14. {
  15. for (MyDataList.MyLinkedListNode comparator = list.head; comparator != current && comparator.nextNode != current; comparator = comparator.nextNode)
  16. {
  17. if (current.data >= comparator.data && current.data <= comparator.nextNode.data)
  18. {
  19. previous.nextNode = current.nextNode;
  20. current.nextNode = comparator.nextNode;
  21. comparator.nextNode = current;
  22. current = previous;
  23. break;
  24. }
  25. }
  26. previous = current;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement