Python data structure are classified into primitive and non primitive
In Python, primitive data structures are basic data types that cannot be
broken into simpler data types, whereas non primitive data structures are
more complex and can be broken down into smaller data types.
Primitive data structures have a fixed size and they are usually smaller in
size than the non primitive data structures.
Non primitive data structures can be larger in size and can grow or shrink
dynamically.
Primitive data structures are simpler. On the other hand, non primitive
data structures are more complex and can be composed of multiple
primitive
data types.
Primitive data structures are used for simple operations. But non primitive
data structures are used for complex operations such as data
manipulation, sorting
or searching
Primitive data types are represented in memory as a simple values, but
non primitive
data types are usually represented in memory as pointers to other
memory locations.
The main primitive data types in Python are integers, float strings and
booleans.
Non primitive data structures are derived from primitive data types by
combining two or more primitive data structures. These data structures
can be subdivided as linear
and non-linear data structures.
Linear data structures are those in which the elements are arranged in a
sequential order with each element connected to its adjacent elements.
These data structures are used to represent a sequence of data where the
order of elements is important.
There are many linear data structures in Python, so these are lists, tuples,
arrays, linked lists, stacks and queue.
Non linear data structures are those in which the elements are not
arranged in a sequential order. These data structures are used to
represent a hierarchical relationship between data elements where each
element is connected to one or more other elements in a specific way.
Sets, dictionaries, trees and graphs are non linear data structures.
We can also subdivide these data structures into built in data structures
and user defined data structures. Built in data structures are the ones
which comes with Python. We don't need to use any external library or
create ourselves these data structures. They are built in in Python. So
from linear data structures, lists and tuples are built in data structures and
from non linear data structures, sets and dictionaries are built in data
structures.
Other data structures that we have over here are user defined data
structures. So this means that we need to use some external library or we
can create them by ourselves to be able to use them.