luishenriique

PAA - Main - Bubble & Merge

Jun 11th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. import java.io.IOException;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) throws IOException {
  5.         long startTime = 0, endTime = 0, time = 0;
  6.         char[] v;
  7.         String dir;
  8.  
  9.         /* Tamanho do vetor
  10.         *  n = 1 -> vet = 10240
  11.         *  n = 2 -> vet = 102400
  12.         *  n = 3 -> vet = 512000
  13.         *  n = 4 -> vet = 1048576
  14.         */
  15.         int n = 1;
  16.  
  17.         dir = Helper.criarArquivo(n);
  18.         v = Helper.lerArquivo(dir);
  19.  
  20.         System.out.println("Tamanho: " + Helper.getTamanho(n) / 1024 + " KB");
  21.  
  22.         startTime = System.currentTimeMillis();
  23.         Order.bubbleSort(v, v.length);
  24.         endTime = System.currentTimeMillis();
  25.         time = endTime - startTime;
  26.         System.out.println("Bubble, tempo gasto: " + time + " ms");
  27.  
  28.         startTime = System.currentTimeMillis();
  29.         Order.mergeSort(v, 0, v.length - 1);
  30.         endTime = System.currentTimeMillis();
  31.         time = endTime - startTime;
  32.         System.out.println("Merge, tempo gasto: " + time + " ms");
  33.  
  34.         System.out.println();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment