title: Recursive BubbleSort vs normal BubbleSort
body: <p>I have coded 2 bubblesort algorithms. One is without recursion, the other is with recursion. I am interested on knowing which of these two are more efficient and with and explain why.</p>
  
  <p>Recursive bubbleSort:</p>
  
  <pre><code>private static int list[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  
  public int[] recursiveBubble(int[] args, int startIndex, int endIndex) {
      if(startIndex &gt; endIndex){
          System.out.println("Recursive bubblesort:");
          System.out.println(Arrays.toString(args));
          return args;
      }
  
      if (startIndex == endIndex - 1) {
          recursiveBubble(args, 0, endIndex - 1);
      } else if (args[startIndex] &gt; args[startIndex+1]) {
          int currentNumber = args[startIndex];
          args[startIndex] = args[startIndex + 1];
          args[startIndex + 1] = currentNumber;
  
          recursiveBubble(args, startIndex + 1, endIndex);
      } else  {
          recursiveBubble(args, startIndex + 1, endIndex);
      } 
      return args;
  }
  </code></pre>
  
  <p>BubbleSort using loops:</p>
  
  <pre><code> public int[] bubblesort(int[] args) {
      System.out.println("Normal BubbleSort:");
      for (int j = 0; j &lt; args.length; j++) {
          for (int i = 0; i &lt; args.length; i++) {
              int currentNumber = args[i];
              if (i + 1 &lt; args.length) {
                  if (currentNumber &gt; args[i + 1]) {
                      args[i] = args[i + 1];
                      args[i + 1] = currentNumber;
                  }
              }
          }
      }
      System.out.println(Arrays.toString(args));
      return args;
  }
  </code></pre>