TreeMap - Search Time Complexity

java_geek picture java_geek · May 19, 2010 · Viewed 24.5k times · Source

What is the time complexity of a get() and put() in a TreeMap?

Is the implementation same as a Red-Black Tree?

Answer

Daniel Renshaw picture Daniel Renshaw · May 19, 2010

From here: http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html

This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations