Guest User

Untitled

a guest
Jun 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3.  
  4. public class LineSort {
  5.  
  6. /**
  7. * @param args the command line arguments
  8. */
  9. public static void main(String[] args) {
  10. ArrayList<Integer> dataSet = new ArrayList<>();
  11. int[] sortedDataSet = new int[20000001];
  12. for (int g = 0; g < 20000000; g++) {
  13. dataSet.add((int) (Math.random() * 20000000));
  14.  
  15. }
  16. double start = System.currentTimeMillis();
  17. for (int i = 0; i < dataSet.size(); i++) {
  18. sortedDataSet[dataSet.get(i)] = sortedDataSet[dataSet.get(i)] + 1;
  19. }
  20.  
  21. for (int z = 0; z < sortedDataSet.length; z++) {
  22. if (sortedDataSet[z] != 0) {
  23. //System.out.print(z + " ");
  24. //System.out.println(z);
  25. sortedDataSet[z] = sortedDataSet[z] - 1;
  26. z--;
  27. } else {
  28.  
  29. }
  30. }
  31. double end = System.currentTimeMillis();
  32. double finished = end - start;
  33. System.out.println(finished / 1000 + " seconds to complete sort");
  34. }
  35. }
Add Comment
Please, Sign In to add comment