Skip to main content

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.

PrimitiveNon-primitive
Basic types defined by the languageDerived (user-defined) from primitive types
Hold a single valueHold a collection of values, possibly of different types
Examples: int, float, char, boolean, pointerExamples: array, stack, queue, linked list, tree, graph, struct
Size is fixed by the machine/compilerSize may be fixed (array) or change at run time (list)
Operated on directly by machine instructionsNeed user-written functions or algorithms
Not divisible into smaller data typesCan be divided into simpler components
Store data in one memory locationStore data in a number of related locations

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 1 questions →