This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Treemap sorting O-notation ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Treemap sorting O-notation ?" Watch "Treemap sorting O-notation ?" New topic
Author

Treemap sorting O-notation ?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

I am sorting resultsets via an integer key using TreeMap.
Does anyone know the O-notation for the data structure
in TreeMap which is a sorted Map ADT.
Thanks
Gavin


Regards,

Pho
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
If you are using the Collections.sort() method, then this quote from the API will answer your question:

The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance, and can approach linear performance on nearly sorted lists.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Treemap sorting O-notation ?
 
Similar Threads
Sorting the countries in Alphabetical Order
Best book for Data Structures and Algorithm?
Sorting the Object Using TreeMap Class
Getting into Google!!!
constant-time performance Collection