Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the better word is tradeoff since there are no perfect data structures for each job. The hasmap has the advantage of O(1) access time but the drawback of memory usage, an unsorted nature and the depends on a good hashing function to minimize collisions. A vector is also O(1), but it has an upfront memory cost that cannot be avoided. A map has a O(Log(n)) access cost, but has less memory usage, is sorted by nature and the comparison function is easier to implement. Three similar data structures, but each with its own tradeoffs.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: