Big O

Common Data Structures and Relative functions:

Lists and Sets:

Structure get add remove contains
ArrayList O(1) O(1) O(n) O(n)
LinkedList O(n) O(1) O(1) O(n)
HashSet O(1) O(1) O(1) O(1)
LinkedHashSet O(1) O(1) O(1) O(1)
TreeSet O(log n) O(log n) O(log n) O(log n)

Maps:

Structure get put remove containsKey
HashMap O(1) O(1) O(1) O(1)
LinkedHashMap O(1) O(1) O(1) O(1)
TreeMap O(log n) O(log n) O(log n) O(log n)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License