Primitive vs non-primitive data structure
Data structure means organizing the data in the memory. The data can be organized in two
ways either linear or non-linear way.
There are two types of data structure available for the programming purpose:
● Primitive data structure
● Non-primitive data structure
Primitive data structure is a fundamental type of data structure that stores the data of only
one type whereas the non-primitive data structure is a type of data structure which is a
user-defined that stores the data of different types in a single entity.
In the above image, we can observe the classification of the data structure. The data
structure is classified into two types, i.e., primitive and non-primitive data structure. In the
case of primitive data structure, it contains fundamental data types such as integer, float,
character, pointer, and these fundamental data types can hold a single type of value. For
example, integer variable can hold integer type of value, float variable can hold floating type
of value, character variable can hold character type of value whereas the pointer variable
can hold pointer type of value.
In the case of non-primitive data structure, it is categorized into two parts such as linear data
structure and non-linear data structure. Linear data structure is a sequential type of data
structure, and here sequential means that all the elements in the memory are stored in a
sequential manner; for example, element stored after the second element would be the third
element, the element stored after the third element would be the fourth element and so on.
, We have different linear data structures holding the sequential values such as Array, Linked
list, Stack, Queue.
Non-linear data structure is a kind of random type of data structure. The non-linear data
structures are Tree and Graph.
Let's understand the differences between the primitive and non-primitive data
structure.
Primitive data structure Non-primitive data structure
Primitive data structure is a kind of data Non-primitive data structure is a type of data
structure that stores the data of only one structure that can store the data of more than
type. one type.
Examples of primitive data structure are Examples of non-primitive data structure are
integer, character, float. Array, Linked list, stack.
Primitive data structure will contain some Non-primitive data structure can consist of a
value, i.e., it cannot be NULL. NULL value.
The size depends on the type of the data In case of non-primitive data structure, size is
structure. not fixed.
It starts with a lowercase character. It starts with an uppercase character.
Primitive data structure can be used to Non-primitive data structure cannot be used to
call the methods. call the methods.
Primitive data structure
Primitive data structure is a data structure that can hold a single value in a specific location
whereas the non-linear data structure can hold multiple values either in a contiguous location
or random locations
The examples of primitive data structure are float, character, integer and pointer. The value
to the primitive data structure is provided by the programmer. The following are the four
primitive data structures:
● Integer: The integer data type contains the numeric values. It contains the whole
numbers that can be either negative or positive. When the range of integer data type
is not large enough then in that case, we can use long.
● Float: The float is a data type that can hold decimal values. When the precision of
decimal value increases then the Double data type is used.
● Boolean: It is a data type that can hold either a True or a False value. It is mainly
used for checking the condition.
● Character: It is a data type that can hold a single character value both uppercase
and lowercase such as 'A' or 'a'.
Data structure means organizing the data in the memory. The data can be organized in two
ways either linear or non-linear way.
There are two types of data structure available for the programming purpose:
● Primitive data structure
● Non-primitive data structure
Primitive data structure is a fundamental type of data structure that stores the data of only
one type whereas the non-primitive data structure is a type of data structure which is a
user-defined that stores the data of different types in a single entity.
In the above image, we can observe the classification of the data structure. The data
structure is classified into two types, i.e., primitive and non-primitive data structure. In the
case of primitive data structure, it contains fundamental data types such as integer, float,
character, pointer, and these fundamental data types can hold a single type of value. For
example, integer variable can hold integer type of value, float variable can hold floating type
of value, character variable can hold character type of value whereas the pointer variable
can hold pointer type of value.
In the case of non-primitive data structure, it is categorized into two parts such as linear data
structure and non-linear data structure. Linear data structure is a sequential type of data
structure, and here sequential means that all the elements in the memory are stored in a
sequential manner; for example, element stored after the second element would be the third
element, the element stored after the third element would be the fourth element and so on.
, We have different linear data structures holding the sequential values such as Array, Linked
list, Stack, Queue.
Non-linear data structure is a kind of random type of data structure. The non-linear data
structures are Tree and Graph.
Let's understand the differences between the primitive and non-primitive data
structure.
Primitive data structure Non-primitive data structure
Primitive data structure is a kind of data Non-primitive data structure is a type of data
structure that stores the data of only one structure that can store the data of more than
type. one type.
Examples of primitive data structure are Examples of non-primitive data structure are
integer, character, float. Array, Linked list, stack.
Primitive data structure will contain some Non-primitive data structure can consist of a
value, i.e., it cannot be NULL. NULL value.
The size depends on the type of the data In case of non-primitive data structure, size is
structure. not fixed.
It starts with a lowercase character. It starts with an uppercase character.
Primitive data structure can be used to Non-primitive data structure cannot be used to
call the methods. call the methods.
Primitive data structure
Primitive data structure is a data structure that can hold a single value in a specific location
whereas the non-linear data structure can hold multiple values either in a contiguous location
or random locations
The examples of primitive data structure are float, character, integer and pointer. The value
to the primitive data structure is provided by the programmer. The following are the four
primitive data structures:
● Integer: The integer data type contains the numeric values. It contains the whole
numbers that can be either negative or positive. When the range of integer data type
is not large enough then in that case, we can use long.
● Float: The float is a data type that can hold decimal values. When the precision of
decimal value increases then the Double data type is used.
● Boolean: It is a data type that can hold either a True or a False value. It is mainly
used for checking the condition.
● Character: It is a data type that can hold a single character value both uppercase
and lowercase such as 'A' or 'a'.