0% found this document useful (0 votes)
85 views1 page

? Java Collections Time Complexity Table

The document provides a table summarizing the time complexity for various Java Collections, including ArrayList, LinkedList, HashMap, TreeMap, HashSet, and TreeSet. It details the read and write times for each collection type, along with explanations for their complexities. Key points include that ArrayList offers fast access but slow insertion/deletion, while TreeMap and TreeSet maintain sorted order with logarithmic complexity.

Uploaded by

saiakshaykv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views1 page

? Java Collections Time Complexity Table

The document provides a table summarizing the time complexity for various Java Collections, including ArrayList, LinkedList, HashMap, TreeMap, HashSet, and TreeSet. It details the read and write times for each collection type, along with explanations for their complexities. Key points include that ArrayList offers fast access but slow insertion/deletion, while TreeMap and TreeSet maintain sorted order with logarithmic complexity.

Uploaded by

saiakshaykv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

📊 Java Collections Time Complexity

Table

Collection Read Write Time 🚀 Why this Complexity?


Time

ArrayList O(1) (get) O(1) for add at Uses indexed array; direct access is
end, O(n) for fast, but inserting/deleting shifts
insert/delete elements.

LinkedList O(n) O(1) at head/tail No indexing; access needs traversal,


but adding/removing nodes is quick at
ends.

HashMap O(1) avg O(1) avg Uses hashing; collisions handled by


O(n) O(n) worst chaining/tree, which can degrade
worst performance.

TreeMap O(log n) O(log n) Internally uses Red-Black Tree


(balanced BST); read/write require
log(n) operations.

HashSet O(1) avg O(1) avg Backed by HashMap; stores values as


O(n) O(n) worst keys with dummy values. Same
worst performance as HashMap.

TreeSet O(log n) O(log n) Backed by TreeMap (Red-Black Tree);


keeps sorted order, hence log(n)
complexity.

You might also like