title: Number of Comparisons between selection sort and bubble sort keep coming up the same
body: <p>I have written this program to compare the number of operations needed to sort a random numbers using both selection and bubble sort. However, these numbers keep coming up the same and I can't figure out where my code went wrong.</p>
  
  <pre><code>static int num_comps;   
  
  public static void main(String[] args) 
  {
      Random rnd = new Random();
  
      // max size of array
      // number of N inputs
      int array_size = 32768;
      int num_datasets = 12;
  
      // allocate array once to the max size
      int[] vals = new int[array_size];
  
      // temp array with allocated array to max size
      int[] tvals = new int[array_size];
  
      // array to hold operation counts
      int[] op_counts = new int[num_datasets];
      int[] op_counts2 = new int[num_datasets];
  
      // array to hold the size of each array
      //
      int[] arraySizes = new int[num_datasets];
  
      int i;
      int j;
      int sz;
  
      for (i = 0, sz = 16; i &lt; num_datasets; i++, sz *= 2)
          arraySizes[i] = sz;
  
      for (int iter = 0; iter &lt; num_datasets; iter++)
      {
          int curr_size = arraySizes[iter];
  
          // load array with random values
          //
          for (i = 0; i &lt; curr_size; i++)
              vals[i] = rnd.nextInt(4999);
  
          for (i = 0; i &lt; curr_size; i++)
              tvals[i] = vals[i];
  
          // run the bubble sort algorithm
          //
          num_comps = 0;
          bubbleSort(tvals, curr_size);
          op_counts[iter] = num_comps;
          //System.out.println("Num comps at " + iter + " is " + num_comps);
  
          // run the selection-sort algorithm
          num_comps = 0;
          selectionSort(tvals, curr_size);
          op_counts2[iter] = num_comps;
          //System.out.println("Num comps at " + iter + " is " + num_comps);
      }
  
      System.out.println("Operation Counts (N vs. op Count): ");
      for (int k = 0; k &lt; num_datasets; k++)
          System.out.println(arraySizes[k] + "\t\t" + op_counts[k] + "\t\t" + op_counts2[k]);
  }
  
  static void bubbleSort(int vals[], int curr_size)
  {
      int temp;
      for (int i = 0; i &lt; curr_size - 1; i++)
      {
          for (int j = 0; j &lt; curr_size - i - 1; j++)
          {
              // swap
              num_comps = num_comps + 1;
              if (vals[j+1] &lt; vals[j])
              {
                  temp = vals[j];
                  vals[j] = vals[j+1];
                  vals[j+1] = temp;
              }
          }
      }
  }
  
  static void selectionSort(int vals[], int curr_size)
  {
      int temp;
      for(int i=0; i&lt;curr_size - 1; i++)
       {
          for(int j=i+1; j&lt;curr_size; j++)
          {
              num_comps = num_comps + 1;
              if(vals[i] &gt; vals[j] )
              {
                  temp = vals[j];
                  vals[j] = vals[i];
                  vals[i] = temp;
              }
          }
       }
  }
  </code></pre>