Past exam question: 2078 Baishakh (Back), Q1
Open in the Padhaiko appQuestion
Compare primitive and non-primitive data structures.
Solution
Comparison of Primitive and Non-Primitive Data Structures:
| Feature | Primitive Data Structures | Non-Primitive Data Structures |
|---|---|---|
| Definition | Fundamental, built-in data types directly supported by machine instructions | Derived structures built from primitive (or other non-primitive) types |
| Structure Complexity | Store a single atomic value per variable | Organize collections of multiple related values |
| Operations | Basic arithmetic, logical, and relational operations (+, -, <, ==) | Structural operations: insertion, deletion, traversal, searching, sorting |
| Memory Layout | Fixed size per type (e.g., 4 bytes for int, 1 byte for char) | Contiguous (arrays) or dynamic scattered nodes (linked lists, trees) |
| Examples | int, float, char, double, pointers | Arrays, Stacks, Queues, Linked Lists, Trees, Graphs |
Answer:
Primitive data structures (int, float, char) are atomic, hardware-supported built-in types storing single values, whereas non-primitive data structures (arrays, stacks, queues, linked lists, trees, graphs) organize multiple values into linear or non-linear relationships with structural operations like insertion, deletion, and traversal.