- 2072 Magh · 2+2 marks
Data structure; primitive vs non-primitive
Short answer
A data structure organizes and stores data for efficient access and manipulation. Primitive structures are built-in types holding one value (int, float) with machine-operated operations, while non-primitive structures are user-defined, hold collections, and require algorithms; they are linear or non-linear.
Define a data structure and also write down the difference between primitive data structure and non-primitive data structure.
A data structure is a particular way of organising and storing data in the memory of a computer so that it can be accessed, searched and modified efficiently. It also includes the set of operations defined on the organised data. Examples: array, stack, queue, linked list, tree, graph.
Primitive vs non-primitive data structures
| Primitive | Non-primitive |
|---|---|
| Basic types built into the language | Derived from primitive types |
| Store one value of a single type | Store a collection of values |
| Examples: int, float, char, pointer | Examples: array, stack, queue, list, tree, graph |
| Operated on directly by the machine | Operated on through user-defined algorithms |
| Fixed size decided by the compiler | Fixed (array) or dynamic (linked list) |
| Cannot be broken into simpler types | Can be broken into simpler components |
Non-primitive structures are further divided into linear (array, list, stack, queue) and non-linear (tree, graph).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Primitive vs non-primitive data structure · Data Structure and Algorithm, chapter 1