Linear data structures have a linear arrangement of elements with a specific order, while nonlinear data structures have more complex relationships and do not follow a strict sequential order.
Complexity analysis helps us understand how the performance of an algorithm or data structure changes as the input size increases.
A slightly formal definition of complexity
Let's
Let's also consider that we have a function
The complexity
- If
$\varphi$ remainsconstant
as$n$ increases, we haveconstant complexity
. The complexity$\gamma$ is then noted as follows:$O(1)$ : this is theBig O notation
.
- If
$\varphi$ increaseslinearly
as$n$ increases, we say we havelinear complexity
.
Note: there are several types of complexity, which we'll examine later with the help of a few case studies.