The Artima Developer Community
Sponsored Link

Java Answers Forum
Quicksort vs Collections.sort()

4 replies on 1 page. Most recent reply: Jun 4, 2002 1:43 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
hhichijo

Posts: 3
Nickname: hhichijo
Registered: Jun, 2002

Quicksort vs Collections.sort() Posted: Jun 2, 2002 11:00 AM
Reply to this message Reply
Advertisement
I have an ArrayList of objects (created by me) which needs to be sorted. I implemented the sort trying both quicksort and also the sort method in class Collections. Would there be any significant difference in these 2 implementations??


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Quicksort vs Collections.sort() Posted: Jun 2, 2002 1:32 PM
Reply to this message Reply
Unless you provide a efficient implementation for the Comparable interface, the self made implementation should be faster but for the Strings where there should be a default implementation in the Framework for these.

Rgds,

Thomas SMETS,
SCJP2 - Brussels

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Quicksort vs Collections.sort() Posted: Jun 2, 2002 4:08 PM
Reply to this message Reply
Since you said you have already implemented the solution, you should be answering the question, not asking it! Use your implemention to perform some tests and let us know the answer.

hhichijo

Posts: 3
Nickname: hhichijo
Registered: Jun, 2002

Re: Quicksort vs Collections.sort() Posted: Jun 2, 2002 5:04 PM
Reply to this message Reply
Thanks for the replies.....

I tried to test the difference by getting the time elapsed using two Gregorian Calendar objects (is this a valid and reliable method??) and the differnce is minimal. This is actually why I posted to seek more advice.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Quicksort vs Collections.sort() Posted: Jun 4, 2002 1:43 PM
Reply to this message Reply
To test your timing you should probably tell us more about the nature of the Objects you wanna / need to store.

You basically will need to make sure the different timing are equivalent but for the "Storage / Retrieval".

Thomas SMETS,
SCJP2 - Brussels

Flat View: This topic has 4 replies on 1 page
Topic: How to Create an Executable File Previous Topic   Next Topic Topic: javaSwings

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use