Fakultas Ilmu Komputer UI

Commit 9ffc4e28 authored by Avatar Azka's avatar Avatar Azka

Created random array generator

parent 6f44c572
......@@ -8,12 +8,15 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import daa.SortingVariant;
import daa.RNG;
public class Main {
public static void main(String[] args) {
// write your code here
int arr[] = {3, 4, 2, 5, 7, 1, 2, 8, 10, 22, 93, 52};
RNG rand = new RNG();
int arr[] = rand.getRandomIntArray(1000, 1, 1000000);
int size = arr.length;
List<Integer> out = bucketSort(arr, size);
......
package daa;
import java.util.Arrays;
import java.util.Random;
public class RNG {
Random rand = new Random();
public int[] getRandomIntArray(int size, int lower, int upper) {
int[] numbers = new int[size];
//Generates 10 Random Numbers in the range 1 -20
for(int i = 0; i < size; i++) {
numbers[i] = (int)(Math.random()*upper + lower);
}
return numbers;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment