Skip to content

🧱 Data Structures

Data structures are the ways we organize and store data in memory so that algorithms can operate efficiently. They determine how quickly we can insert, delete, search, sort, or traverse data. Choosing the right data structure is just as important as choosing the right algorithmβ€”often more important.


Data structures are specialized formats for organizing, storing, and accessing data efficiently. They define how data is laid out in memory and what operations can be performed quickly.

They answer:

  • How should this data be stored?
  • How can we access it efficiently?
  • What operations must be fast?

The choice of data structure affects:

  • Performance (time complexity)
  • Memory usage
  • Scalability
  • Algorithm efficiency
  • Code clarity
  • Reliability

A poor data structure can make a fast algorithm slow; a good one can make a slow algorithm fast.


Organize data sequentially.

  • Arrays β€” fixed-size, fast indexing
  • Linked lists β€” dynamic size, fast insertion/deletion
  • Stacks β€” LIFO operations
  • Queues β€” FIFO operations
  • Deques β€” double-ended queues

Provide fast lookups using hashing.

  • Hash tables β€” average O(1) lookup
  • Hash sets β€” unique elements
  • Hash maps β€” key-value storage

Organize data hierarchically.

  • Binary trees β€” hierarchical structure
  • Binary search trees β€” sorted hierarchical structure
  • AVL trees β€” self-balancing BST
  • Red-black trees β€” balanced insert/delete
  • Heaps β€” priority queues
  • Tries β€” prefix-based lookup (strings)

Represent relationships and networks.

  • Graphs β€” nodes + edges
  • Adjacency lists β€” efficient sparse graph representation
  • Adjacency matrices β€” efficient dense graph representation

Optimized for specific use cases.

  • Sets β€” unique collections
  • Maps β€” key-value pairs
  • Bloom filters β€” probabilistic membership tests
  • Segment trees β€” range queries
  • Fenwick trees β€” prefix sums
  • LRU caches β€” eviction-based caching

Choose based on:

  • Access pattern β€” random access vs sequential
  • Update pattern β€” frequent inserts/deletes vs static data
  • Search needs β€” exact match vs range queries
  • Memory constraints β€” small vs large datasets
  • Performance requirements β€” O(1), O(log n), O(n)
  • Data relationships β€” hierarchical, graph-like, sequential

Data structure choice often determines algorithm choice.


Different data structures offer different performance guarantees:

Data StructureLookupInsertDeleteNotes
ArrayO(1)O(n)O(n)Fast indexing, slow modification
Linked ListO(n)O(1)O(1)Fast insertion, slow search
Hash MapO(1)*O(1)*O(1)*Average case; collisions matter
BSTO(log n)O(log n)O(log n)Requires balancing
HeapO(1)O(log n)O(log n)Priority queue
GraphvariesvariesvariesDepends on representation

If you apply data structures to a Daily Scrum application:

  • Tasks β†’ stored in a list or hash map for fast lookup
  • Daily summaries β†’ stored in a tree or sorted list for ordering
  • Notifications β†’ priority queue (heap) for scheduling
  • Team members β†’ hash map keyed by ID
  • PDF generation β†’ tree-like structure for layout elements

Choosing the right data structure ensures performance and clarity.


Data structures are specialized ways of organizing data to support efficient operations. They directly influence performance, scalability, and algorithm efficiency. Good software design requires choosing the right data structure for the right problem.