A Data Structure is a mathematical or logical model of organizing data items in memory, coupled with a set of operations that can be performed upon them. An Abstract Data Type (ADT) formalizes this concept by specifying what operations can be performed on the data without dictating how those operations must be implemented in hardware or software.
Data structures are taxonomically classified into two principal dimensions:
- Primitive vs. Non-Primitive: Primitive data structures (e.g.,
int,float,char,bool) are directly manipulated by underlying machine-level processor instructions. Non-primitive data structures are composite arrangements constructed from primitive types (e.g., arrays, structures, classes). - Linear vs. Non-Linear: In a Linear Data Structure, data elements form a sequential or one-to-one relationship where every element (except the first and last) has a unique predecessor and successor. In a Non-Linear Data Structure, elements exhibit hierarchical, one-to-many, or many-to-many multi-level relationships.
- Static vs. Dynamic: Static data structures allocate a fixed block of contiguous memory at compilation time (e.g., static arrays), while dynamic structures allocate and free memory nodes on-demand during runtime on the system heap (e.g., linked lists, trees).
Every comprehensive data structure supports a canonical suite of primitive operations:
- Traversal: Processing every data node exactly once to read, print, or evaluate its contents.
- Insertion: Incorporating a new data record into the structure at a designated position.
- Deletion: Removing an existing data record from the structure and reclaiming its memory.
- Searching: Locating the memory address or index of a target record possessing a specified search key.
- Sorting: Rearranging data elements into a strictly monotonic ascending or descending sequence.
- Merging: Combining two distinct sorted structures into a single unified sorted structure.
| Structural Category | Element Organization | Memory Allocation | Traversal Complexity | Primary Examples |
|---|---|---|---|---|
| Linear Structures | Single-level sequential order (predecessor / successor) | Contiguous (arrays) or Non-contiguous via pointers (lists) | $O(n)$ single-pass iteration | 1D/2D Arrays, Stacks, Queues, Linked Lists |
| Non-Linear Structures | Hierarchical multi-level or interconnected networks | Non-contiguous heap dynamic memory using node pointers | Non-linear recursive paths (e.g., Pre/In/Post-order) | Binary Trees, Binary Search Trees (BST), Graphs |