Basic Data Structures for Programmers
We will not be talking about data structures implementation in this post, but about their usage or choice during programming. Let’s start from the basic definition.
What is a Data Structure?
Data Structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. They can be broadly classified as primitive, composite, abstract data structures. Primitive structures are the basic units of storage like boolean, integer, float, double. These are not that significant when compared to other types. Let’s discuss their usage.
Important Data Structures & Usage:
Arrays: When index (position) based access is needed in your program while accessing a collection of same data type
List: Structures and Iterators — When there is a need for accessing a collection of same data type and need of dynamically growing collection
Stacks: When there is a need for implementing undo\redo operation (like in word processors)
Queues: When there is a need for implementing some ordering based on some attribute especially FIFO type of operation. There are lot of variations but important one is the ‘Priority queues’, which is used for process scheduling in many OS kernels
Trees: For complex requirements like building a Parsers, Filesystem, IP routing table, 3D computer graphics with many layered objects
Min and Max Heaps: Mostly used in Greedy based algorithms
Graphs: When there is need to represent or model — connections/relations in social networking sites, Routing, networks of communication
Hash Tables: When requirement is ‘fast data lookup’. Symbol table for compilers, database indexing, caches uses Hash table in their implementation
Trie: When you need to implement auto-completion and spell-checking kind of functionality