Big-O cheat sheet
The real cost of the operations you repeat, for the collections you actually use.
Open this lesson in the learning hubKey points
ArrayList:getO(1), append amortised O(1), insert or remove in the middle O(n),containsO(n).LinkedList: add or remove at either end O(1), anything by index or by value O(n).HashMapandHashSet: get, put and contains O(1) on average, O(log n) in a treeified bucket.TreeMapandTreeSet: every lookup, insert and range query O(log n), and the keys stay sorted.ArrayDeque: both ends O(1).PriorityQueue: offer and poll O(log n), peek O(1).- Constants still matter: scanning a 100-element ArrayList often beats a HashMap lookup. Measure before you switch.
Choose by the operation you repeat most, not by the collection you type most.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Collections course, and every lesson in it is listed on the Collections contents page.