Is list::size() really O(n)?

In C++11 it is required that for any standard container the .size() operation must be complete in “constant” complexity (O(1)). (Table 96 — Container requirements). Previously in C++03 .size() should have constant complexity, but is not required (see Is std::string size() a O(1) operation?). The change in standard is introduced by n2923: Specifying the complexity … Read more

Big-O summary for Java Collections Framework implementations? [closed]

The book Java Generics and Collections has this information (pages: 188, 211, 222, 240). List implementations: get add contains next remove(0) iterator.remove ArrayList O(1) O(1) O(n) O(1) O(n) O(n) LinkedList O(n) O(1) O(n) O(1) O(1) O(1) CopyOnWrite-ArrayList O(1) O(n) O(n) O(1) O(n) O(n) Set implementations: add contains next notes HashSet O(1) O(1) O(h/n) h is … Read more