From 3a19175f16f28eea198a85d3e25eee672832b7ea Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 24 Nov 2019 13:28:04 -0600 Subject: This project is no funno --- csci1913/Java/project2_strap012.java | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'csci1913/Java/project2_strap012.java') diff --git a/csci1913/Java/project2_strap012.java b/csci1913/Java/project2_strap012.java index ee09265..69793f0 100644 --- a/csci1913/Java/project2_strap012.java +++ b/csci1913/Java/project2_strap012.java @@ -54,32 +54,29 @@ class Sort { // NUMBER slots, without making new NODEs. private static Node sortNodes(Node unsorted) { - Node left = null, right = null, sorted = null; if (unsorted==null || unsorted.next==null) { - //unsorted list is either empty or of length 1 + //unsorted is either empty or of length 1 return unsorted; - } else { - //Halving phase - int step = 1; - while (unsorted != null) { - if (step % 2 == 0) { //Odd case - if (right == null) { - right = unsorted; - } else { - - } - } else { //Even case - if (left == null) { - left = unsorted; - } else { - - } + } //Halving phase + Node left = null, right = null, sorted = null; + int step = 1; + while (unsorted != null) { + if (step % 2 == 0) { //Odd case + if (right == null) { + right = unsorted; + } else { + right.next = unsorted; + } + } else { //Even case + if (left == null) { + left = unsorted; + } else { + left.next = unsorted; } - step++; - unsorted = unsorted.next; } + step++; + unsorted = unsorted.next; } - return sorted; } -- cgit v1.2.3