Are they AVL trees, red-black trees, or something else?
+4
A:
The first sentence of the TreeMap Javadoc states:
A Red-Black tree based
NavigableMap
implementation.
matt b
2010-08-27 01:46:38
+5
A:
From the java.util.TreeMap<K,V>
documentation:
A Red-Black tree based
NavigableMap
implementation.
For questions like these, you should always first consult the documentation. The API shouldn't describe ALL of the inner-workings of a class
, but elementary informations such as general data structures and algorithms used are usually documented.
Other Java Collections Framework trivias
These are all little trivias that are also clearly documented:
TreeSet
is implemented with aTreeMap
HashSet
is implemented with aHashMap
Collections.sort
uses modified mergesortMap<K,V>
is not aCollection<?>
ArrayList
doesn't specify exact growth policy (unlike, say,Vector
)
Related questions
polygenelubricants
2010-08-27 01:56:44
A:
TreeSet is based on TreeMap. And they uses red-black tree, red-black tree is a kind of AVL.
卢声远 Shengyuan Lu
2010-08-27 03:00:32
Red-black trees and AVL trees are two different things.
Craig P. Motlin
2010-08-27 04:13:37