Data sorting: Bubble Sort or Collections Sort method

Asked

Viewed 221 times

2

Which is more efficient to sort a large amount of data passed through an array:

  • Bubble Sort
  • Using the own resources of Collections, for example the method Sort.

1 answer

2


The Java Sort method uses merge Sort which is guaranteed to act with an efficient complexity (n log n) with any type of data. Which is much better than the Bubble Sort which is N2.

Between the two options, keep the resources of Collections.

Now, there is the possibility that if you understand the sorting algorithms, you can optimize and improve performance. I recommend this study if you think it’s not serving you as well as the algorithm yet.

  • I am studying to understand how the two work, today with the advancement of hardware, and the practicality that Collection gives us, it is better to finish it, could put in my question..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.