The **key difference** between linear and nonlinear data structure is that **in linear data structures, the organization of data elements are sequential while in nonlinear data structures, the organization of data elements is not sequential. **

A data structure is a method for organizing and storing data, which would allow efficient data retrieval and usage. Linear data structure is a structure that organizes its data elements one after the other. The organization of linear data structures is similar to the organization of the computer memory. Construction of Nonlinear data structures occurs by attaching a data element to several other data elements in such a way that it reflects a specific relationship among them. Organization of nonlinear data structures is different than the computer’s memory.

### CONTENTS

1. Overview and Key Difference

2. What is Linear Data Structures

3. What is Nonlinear Data Structures

4. Side by Side Comparison – Linear vs Nonlinear Data Structures in Tabular Form

5. Summary

## What is Linear Data Structures?

Linear data structures organize their data elements in a linear fashion, where each data element attaches one after the other. In linear data structures, the data elements traverse one after the other and only one element can be directly reached while traversing. Furthermore, linear data structures are very easy to implement, since the organization of the computer memory is also in a linear fashion.

Some commonly used linear data structures are arrays, linked lists, stacks, and queues. Firstly, an array is a collection of data elements of the same type. The index helps to identify each element in the array. Secondly, a linked list is a sequence of nodes, where each node is made up of a data element and a reference to the next node in the sequence. Thirdly, a stack is also a linear data structure. It is only possible to add or remove data elements from the top of the list. Fourthly, a queue is also a list. It allows to add data elements from one end of the list and to remove from the other end of the list.

## What is Non-Linear Data Structures?

In nonlinear data structures, the organization of the data elements is not in a sequential fashion. It is possible to attach a data item in a nonlinear data structure to several other data elements to reflect a special relationship among them. Furthermore, it is not possible to traverse through the items in a single run.

Data structures like trees and graphs are some examples of nonlinear data structures. Firstly, a tree is a data structure that is made up of a set of linked nodes. It allows representing a hierarchical relationship among data elements. Secondly, a graph is a data structure that is made up of a finite set of edges and vertices. The vertices stored data elements and edges represent the connections or relationships among the vertices.

## What is the Difference Between Linear and Nonlinear Data Structures?

Linear data structures organize the data elements in a sequential manner, and it is possible to traverse the data elements in a single run in a liner data structure. Furthermore, it is easier to implement linear data structures. Array, Stack, Queue, Linked List are some examples of linear data structures.

Nonlinear data structures do not organize the data in a sequential manner and it not possible to traverse the data elements in a single run in a nonlinear data structure. Furthermore, it is difficult to implement nonlinear data structures. Tree and Graph are some examples of nonlinear data structures.

## Summary – Linear vs Nonlinear Data Structures

The difference between linear and nonlinear data structure is that in linear data structures, the organization of data elements are sequential while in nonlinear data structures, the organization of data elements is not sequential. In brief, it is easy to implement linear data structures in the computer memory than the nonlinear data structures. Selecting one data structure type over the other should be done carefully by considering the relationship among the data elements that need to be stored.

##### Reference:

1. Nakum, Shail. “TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)….” *LinkedIn SlideShare*, 1 Aug. 2016. Available here

##### Image Courtesy:

1.’Data stack’By Boivie – Own work (Public Domain) via Commons Wikimedia

2.’Binary search tree’By No machine-readable author provided. (Public Domain) via Commons Wikimedia

Sourav Kundu says

Thanks a lot for this article. Wonderfully explained. 🙂

nav says

nice

sudhakaran says

hm..

vinayak says

nice

Kaustubh Shinde says

Thanks for article..wonderfully explained.

Mohsin Ali says

Could not be explained any better. Prefect.

Rakshanda says

thank u so much