• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

number sorting algorithms

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read Bubblesort was bad, unfortunately by then I had already learned it , So I learned the Selection Sort, which is from what I gather better but still not very efficent for large arrays.

I am wondering how the different sorting algorithms rank by performance? and which are the least complex ones to learn? I'm particularly interested in the beginner-intermediate ones, because the more complex ones I don't think I could grasp.

Ah, I am well aware of the Arrrays.sort() from the java API, but that just isn't as much fun

Thanks,
Mike
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If somebody told you bubble sort was bad, they were wrong - because that is not the COMPLETE story. Different sorts all have strengths and weaknesses. Bubble sorts are great if the data is already mostly sorted. For example, take something like a phone book. It's already sorted. If you want to add 10 names, you can stick them at the end, and use a bubble sort. It would run pretty quick.

Something like a Quicksort, which is good for randomly distributed data, would be HORRIBLE on an already sorted list.

Bubble sort is one of the least complex, which is usually why you learn it first. You can find entire college classes on this topic. Donald Knuth wrote a famous series of books on computer programming. One of them (an entire book) is on nothing but searching and sorting.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
#24 in the http://faq.javaranch.com/java/JavaBeginnersFaq should be of interest to you.
 
Michael Keisu
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys - appreciate the quick replies.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic