Skip to main content

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

PrimitiveNon-primitive
Basic types built into the languageDerived from primitive types
Store one value of a single typeStore a collection of values
Examples: int, float, char, pointerExamples: array, stack, queue, list, tree, graph
Operated on directly by the machineOperated on through user-defined algorithms
Fixed size decided by the compilerFixed (array) or dynamic (linked list)
Cannot be broken into simpler typesCan 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)

All Data Structure and Algorithm chapter 1 questions →