- 2073 Bhadra · 4 marks
Primitive vs non-primitive data structure
Short answer
Primitive data structures are basic language types storing a single value with fixed size, like int or char; non-primitive structures are derived from them, store collections of values, can be linear (array, list) or non-linear (tree, graph), and may have dynamic size.
Differentiate between primitive and non-primitive data structure.
Primitive data structures are the basic data types provided by the language and directly operated on by machine instructions. Non-primitive data structures are derived from primitive ones and store collections of related values.
| Primitive | Non-primitive |
|---|---|
| Basic types defined by the language | Derived (user-defined) from primitive types |
| Hold a single value | Hold a collection of values, possibly of different types |
| Examples: int, float, char, boolean, pointer | Examples: array, stack, queue, linked list, tree, graph, struct |
| Size is fixed by the machine/compiler | Size may be fixed (array) or change at run time (list) |
| Operated on directly by machine instructions | Need user-written functions or algorithms |
| Not divisible into smaller data types | Can be divided into simpler components |
| Store data in one memory location | Store data in a number of related locations |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Data structure; primitive vs non-primitive · Data Structure and Algorithm, chapter 1