- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Explain the Difference Between Linear and Non-linear Data Structure

In this post, we will understand the difference between linear data structure and non-linear data structure.

## Linear Data Structure

The elements of such a structure are arranged sequentially.

Every element can be accessed by traversing through the linear structure.

All the elements of a linear structure are at a single level, i.e there is no hierarchy.

They are easy to implement and use.

They utilize more memory, hence they are not very memory-friendly.

The time complexity of linear data structure usually increases when the size of the structure increases.

Examples include- list, array, stack

The below shows an example of a list in Python.

my_list = [45, 42, 12, 34, 56, 7] print(my_list)

## Output

[45, 42, 12, 34, 56, 7]

## Non-linear Data Structure

The elements are stored in a hierarchical fashion.

They are connected to each other using ‘nodes’.

The elements of this structure are present at different levels, not a single level.

Their implementation is not easy.

They can’t be traversed easily- it requires multiple iterations to completely walk through a non-linear data structure.

They are memory-friendly, i.e they use memory efficiently.

The time complexity of a non-linear data structure remains same even when the size of the data increases.

Examples include- Map, tree, graph

The below example shows how a graph is defined- it indicates that node interconnection also has to be defined.

## Example

graph = {'A': ['B', 'C'], 'B': ['C'], 'C': ['D', 'E'], 'D': ['C'], 'E': ['F', 'G'], 'F': ['C']}

- Related Questions & Answers
- Difference between Linear and Non-linear Data Structures
- What is the difference between Linear and Non-Linear pipeline processors in computer architecture?
- Explain linear data structure queue in C language
- Signals and Systems: Linear and Non-Linear Systems
- Linear Probing in Data Structure
- Difference Between Linear and Logistic Regression
- Difference Between Linear Queue and Circular Queue
- Difference Between Linear Search and Binary Search
- Difference between data type and data structure
- Secant method to solve non-linear equation
- Floyd Cycle Detection Algorithm to detect the cycle in a linear Data Structure
- What is the difference between Linear Cryptanalysis and Differential Cryptanalysis in Information Security?
- How can non-linear data be fit to a model in Python?
- Linear and Nonlinear Resistors
- Linear Search