Download benchmarks/quixbugs/java/BUCKETSORT.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 858 Bytes
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/BUCKETSORT.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/quixbugs/java/BUCKETSORT.java
-
curl -L -o BUCKETSORT.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/BUCKETSORT.java
858 Bytes
| import java.util.*; | |
| /** | |
| * Bucket Sort | |
| * | |
| * | |
| * Input: | |
| * arr: A list of small ints | |
| * k: Upper bound of the size of the ints in arr (not inclusive) | |
| * | |
| * Precondition: | |
| * all(isinstance(x, int) and 0 <= x < k for x in arr) | |
| * | |
| * Output: | |
| * The elements of arr in sorted order | |
| * | |
| * @author derricklin | |
| */ | |
| public class BUCKETSORT { | |
| public static ArrayList<Integer> bucketsort(ArrayList<Integer> arr, int k) { | |
| ArrayList<Integer> counts = new ArrayList<Integer>(Collections.nCopies(k,0)); | |
| for (Integer x : arr) { | |
| counts.set(x,counts.get(x)+1); | |
| } | |
| ArrayList<Integer> sorted_arr = new ArrayList<Integer>(100); | |
| int i = 0; | |
| for (Integer count : counts) { | |
| sorted_arr.addAll(Collections.nCopies(count, i)); | |
| i++; | |
| } | |
| return sorted_arr; | |
| } | |
| } | |