DEV Community

Discussion on: Data Structures and Algorithms: 0 to 60

Collapse
 
redligot2009 profile image
redligot2009 • Edited

I think it is important to point out that the Map in this post actually refers to HashMap which is actually a specific type of Map. The problem with HashMap is, due to it using hashes underneath, it's only used when you don't need to know the order of elements. The more general version of a Map utilizes a self-balancing Red-Black binary tree underneath which does O(log N) insertion/deletion but maintains order unlike HashMap. EDIT: Additionally, another one of the weaknesses of HashMap is the possibility for occasional collisions that result in O(n) time delay. Unlike the more widely used general Red-Black tree implementation of Map, HashMap is entirely dependent on the hash function for its speed.