From af80bb88cf7cfc16654a75c7154bb90201f36e8d Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Mon, 25 Nov 2019 11:57:42 -0600 Subject: Hoisting the white flag of surrender --- csci1913/Java/project2_strap012.java | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'csci1913/Java') diff --git a/csci1913/Java/project2_strap012.java b/csci1913/Java/project2_strap012.java index ae4be3f..d8e10ee 100644 --- a/csci1913/Java/project2_strap012.java +++ b/csci1913/Java/project2_strap012.java @@ -83,30 +83,28 @@ class Sort { Node end = null; if (left.number < right.number) { Node temp = left.next; - sorted=left; - end = left; + sorted = left; end = left; left.next = null; left = temp; end.next = null; - } else if (right.number > left.number) { + } else { Node temp = right.next; - end = right; - sorted = right; - right.next =null; + end = right; sorted = right; + right.next = null; right = temp; end.next = null; } while (left != null && right != null) { - if (left.number > right.number) { - right.next = end; - Node temp = right.next; - right.next = null; - end = temp; - } else { - left.next = end; + if (left.number < right.number) { Node temp = left.next; - left.next = null; - end = temp; + end = left; + right = temp; + end.next = null; + } else { + Node temp = right.next; + end = right; + right = temp; + end.next = null; } } if (left == null) { -- cgit v1.2.3