aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java/project2_strap012.java
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-11-24 13:28:04 -0600
committerRossTheRoss <msattr@gmail.com>2019-11-24 13:28:04 -0600
commit3a19175f16f28eea198a85d3e25eee672832b7ea (patch)
treee89b47820d2a3b5a1edd4bbd24fa795addebaa18 /csci1913/Java/project2_strap012.java
parentLeave this shit be (diff)
downloadhomework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar.gz
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar.bz2
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar.lz
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar.xz
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.tar.zst
homework-3a19175f16f28eea198a85d3e25eee672832b7ea.zip
This project is no funno
Diffstat (limited to 'csci1913/Java/project2_strap012.java')
-rw-r--r--csci1913/Java/project2_strap012.java39
1 files changed, 18 insertions, 21 deletions
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;
}