This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 776

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 ?
It's not a secret anymore!