4 ms·
Ask HN: Examples of data structures in real world examples
I'm familiar with most of the common data structures and how to implement them, but I still struggle with understanding how they're used in real world situations. Obviously things like hash maps and queues are pretty common in a lot of codebases, but are there any examples of how data structures like linked lists and trees and stacks are used?
For what it's worth, I'm mostly familiar with web apps so maybe they're just not as common there.
- cottonseed 9y agoWeb apps examples: The children of a DOM node form a linked list, see Node.{firstChild, lastChild, nextSibling, previousSibling}: https://developer.mozilla.org/en-US/docs/Web/API/Node https://developer.mozilla.org/en-US/docs/Web/API/Node What's more, the DOM form a tree: nodes have parents and children. Stacks? Your programming language, whatever it is, uses a stack, the call stack, to keep track of what functions are being called.
- bsvalley 9y agoIt's the difference between a programming language and its implementation. All the things we manipulate as programmers these days are mostly high level. Though, they are mostly made out of addresses and pointers in memory. Example: Array(API) = Linked List(Implementation) = address + pointers(Memory)
- dmlittle 9y agoSnapchat uses linked-listed to keep track of who you're going to send a snap to. Internet routers use queues to create a buffer of packets that have yet to be processed. Postgres uses trees or hashes to create table indices for faster queries. Medium uses Bloom Filters to check if a user has read an article or not.
- fiftyacorn 9y agoI ran a bigquery for java projects on github - was interesting to see the majority of projects using ArrayList and HashMap. I mean i didnt drill down into the datasets - but you could use a similar approach to see how structures are used