Skip to content

Commit 5635864

Browse files
committed
update hw10
1 parent 04d13a8 commit 5635864

File tree

1 file changed

+11
-5
lines changed
  • UCB CS61B/Homework and Projects/homework/hw10/sort

1 file changed

+11
-5
lines changed

UCB CS61B/Homework and Projects/homework/hw10/sort/Sorts.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public static int[] countingSort(int[] keys, int whichDigit) throws QueueEmptyEx
3636
throw new IllegalArgumentException("Illeagle argument " + whichDigit);
3737
}
3838

39-
LinkedQueue[] queues = new LinkedQueue[1 << 4];
40-
for(int i = 0; i < 16; i++)
41-
{
42-
queues[i] = new LinkedQueue();
43-
}
39+
LinkedQueue[] queues = initQueueArr(1 << 4);
4440
int shift = whichDigit * 4;
4541
int com = 0x0F << shift;
4642

@@ -63,6 +59,16 @@ public static int[] countingSort(int[] keys, int whichDigit) throws QueueEmptyEx
6359
}
6460
return keys;
6561
}
62+
63+
private static LinkedQueue[] initQueueArr(int length)
64+
{
65+
LinkedQueue[] queues = new LinkedQueue[length];
66+
for(int i = 0; i < length; i++)
67+
{
68+
queues[i] = new LinkedQueue();
69+
}
70+
return queues;
71+
}
6672

6773
/**
6874
* radixSort() sorts an array of int keys (using all 32 bits

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy