Data ordering: Bubble sort or Collections sort method

2

Which is more efficient to sort a large amount of data passed by a vector:

  • Bubble sort
  • Use the Collections features, for example the Sort method.
asked by anonymous 29.03.2016 / 05:16

1 answer

2

Java's sort method uses merge sort which is guaranteed to perform with an efficient complexity (n log n) with any data type. What is much better than bubble sort which is n2.

Between the two options, stay with Collections features.

Now, there is the possibility that if you understand sorting algorithms, you can optimize and improve performance. I recommend this study if you feel that you are not meeting the algorithm so well.

    
29.03.2016 / 14:04