Data Structures
What Is a Data Structure?
A data structure is a way of organizing data in memory, such as an array, list, stack or tree, so a program can use it efficiently.
Definition
A data structure is a format for storing and organizing data so a program can use it efficiently. The choice decides how fast you can add, find, update and remove items.
Common ones are arrays, linked lists, stacks, queues, hash tables, trees and graphs. Each is fast at some operations and slow at others.
How it works
Linear structures (arrays, linked lists, stacks, queues) keep items in a sequence. Non-linear ones (trees, graphs) connect items in branches or networks. Hash tables map keys to values for near-instant lookup.
Choosing one starts with the operation you need most. If you look things up by key, use a hash table. If you need first-in, first-out order, use a queue.