File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Treemap sorting O-notation ?" Watch "Treemap sorting O-notation ?" New topic

Treemap sorting O-notation ?

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 782

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.


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.
I agree. Here's the link:
subject: Treemap sorting O-notation ?
jQuery in Action, 3rd edition