What is Linear Data Structure? List of Data Structures Explained

Data structures are the data structured in a way for efficient use by the users. As the computer program relies hugely on the data and also requires a large volume of data for its performance, therefore it is highly important to arrange the data. This arrangement of data in organized structures is known as a data structure.

Storing of the data in data structures allows the access, modifications, and other operations that can be carried over the data elements. The arrangement of the data is mainly done in a computer and therefore proper algorithms are required to carry on operations with the data structures. Reducing space and decreasing the time complexity of different tasks is the main aim of data structures.

Learn data science courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

The most important points in a data structure are:

  • A large amount of data is organized through every type of data structure.
  • A particular principle is followed by every data structure.
  • The basic principle of the data structure should be followed even if any operations are carried out over the data structure. 

Arrangement of the data within a data structure can follow different orders. A data structure is therefore classified according to the way of arrangement of the data. Basically, there are two types of data structure.

  1. Primitive data structure
  2. Non-primitive data structure

 The primitive type of data structure includes the predefined data structures such as char, float, int, and double.

The non-primitive data structures are used to store the collection of elements. This data structure can be further categorized into

  1. Linear data structure
  2. Non-Linear data structure. 

Read: Learn the differences between linear and non linear data structure

What is Linear Data Structure: Definition and Characteristics

It is a type of data structure where the arrangement of the data follows a linear trend. The data elements are arranged linearly such that the element is directly linked to its previous and the next elements. As the elements are stored linearly, the structure supports single-level storage of data. And hence, traversal of the data is achieved through a single run only.


  • It is a type of data structure where data is stored and managed in a linear sequence. 
  • Data elements in the sequence are linked to one after the other.
  • Implementation of the linear structure of data in a computer’s memory is easy as the data is organized sequentially.
  • Array, queue. Stack, linked list, etc. are examples of this type of structure.
  • The data elements stored in the data structure have only one relationship.
  • Traversal of the data elements can be carried out in a single run as the data elements are stored in a single level.
  • There is poor utilization of the computer memory if a structure storing data linearly is implemented.
  • With the increase in the size of the data structure, the time complexity of the structure increases.

Must read: Learn excel online free!

These structures can therefore be summarized as a type of data structure where the elements are stored sequentially and follow the order where:

  • Only one first element is present which has one next element.
  • Only one last element is present which has one previous element.
  • All the other elements in the data structure have a previous and a next element

Our learners also read: Data structures and Algorithms free course!

upGrad’s Exclusive Data Science Webinar for you –

How to Build Digital & Data Mindset

Explore our Popular Data Science Courses

You can use linear data structure in C, C++, Python, JavaScript, or any other programming language you are familiar with.

If you get baffled when given a list of linear structures and wonder which of the following is a linear data structure, here’s a rundown of the types. 

Types of Linear Data Structures

Operations performed on linear data structure include insertion, deletion, searching, traversing, and sorting. All these operations serve as the foundation for linear data structures.

Discussed below are the linear data structure types and the corresponding operations on linear data structures that can be performed. You can also look for what is linear data structure with  examples to develop a robust idea. 

1. Array

The array is that type of structure that stores homogeneous elements at memory locations which are contiguous. The same types of objects are stored sequentially in an array. The main idea of an array is that multiple data of the same type can be stored together. Before storing the data in an array, the size of the array has to be defined. Any element in the array can be accessed or modified and the elements stored are indexed to identify their locations.

An array can be explained with the help of a simple example of storing the marks for all the students in a class. Suppose there are 20 students, then the size of the array has to be mentioned as 20. Marks of all the students can then be stored in the created array without the need for creating separate variables for marks for every student. Simple traversal of the array can lead to the access of the elements.

Arrays incorporate the use of zero-based indexing techniques. This means users can access the first element with an index of 0, the second with an index of 1, and so on. Another remarkable feature of this linear data structure is that arrays provide a constant time of O(1) to access the elements, which means that it takes equal time to access any element in the series, disregarding the size of the array.

Types of array:

  • One-dimensional array: This is a simple form of array that contains elements, all of which are the same type of data, in a single row. 
  • Two-dimensional array: This is also known as a matrix. This type of data structure has rows and columns and appears like a grid. The elements can be accessed using two indices- one for column and one for row. 
  • Multi-dimensional array: These arrays have more than two dimensions. 

Operations Performed on Arrays:

The following operations can be performed on arrays:

  • Accessing an element: Accessing an element by its index is an essential operation that can be performed on arrays. It is a constant time operation with a time complexity of O(1). 
  • Inserting or deleting elements: Inserting elements at the end of an array is a constant-time operation having complexity O(1). But inserting an element at the beginning takes O(n) time since all the elements have to be shifted. 

The same goes for deletion of elements in an array.

  • Searching for elements: For unsorted data, linear search takes O(n) time, and for sorted data, binary search takes O(logn) time. 

2. Linked list

The linked list is that type of data structure where separate objects are stored sequentially. Every object stored in the data structure will have the data and a reference to the next object. The last node of the linked list has a reference to null. The first element of the linked list is known as the head of the list. There are many differences between a linked list to the other types of data structures. These are in terms of memory allocation, the internal structure of the data structure, and the operations carried on the linked list. 

Getting to an element in a linked list is a slower process compared to the arrays as the indexing in an array helps in locating the element. However, in the case of a linked list, the process has to start from the head and traverse through the whole structure until the desired element is reached. In contrast to this, the advantage of using linked lists is that the addition or deletion of elements at the beginning can be done very quickly. 

Our learners also read: Free Python Course with Certification

There are three types of linked lists:

  • Single Linked List: This type of structure has the address or the reference of the next node stored in the current node. Therefore, a node which at the last has the address and reference as a NULL. Example: A->B->C->D->E->NULL.
  • A Double Linked List: As the name suggests, each node has two references associated with it. One reference directs to the previous node while the second reference points to the next node. Traversal is possible in both directions as reference is available for the previous nodes. Also, explicit access is not required for deletion. Example: NULL<-A<->B<->C<->D<->E->NULL.
  • Linked List which is circular: The nodes in a circular linked list are connected in a way that a circle is formed. As the linked list is circular there is no end and hence no NULL. This type of linked list can follow the structure of both singly or doubly. There is no specific starting node and any node from the data can be the starting node. The reference of the last node points towards the first node. Example: A->B->C->D->E.

Properties of a linked list are:

  • Access time: O(n)
  • Searching time: O(n)
  • Adding element: O(1) 
  • Deleting  an Element : O(1) 

3. Stack

The stack is another type of structure where the elements stored in the data structure follow the rule of LIFO (last in, first out) or FILO (First In Last Out). Two types of operations are associated with a stack i.e. push and pop. Push is used when an element has to be added to the collection and pop is used when the last element has to be removed from the collection. Extraction can be carried out for only the last added element.

Types of stack:

There are two types of stacks: 

  • Fixed-size stack: This kind of stack does not grow or shrink. Once full, any attempt to add an element will lead to an overflow error. Similarly, an attempt to remove an element will also display an underflow error.
  • Dynamic size stack: This kind of stack can grow or shrink. When a stack is full or empty, it can automatically resize to accommodate a new element or shrink in size. 

Other operations are: 

  • top(): This operation helps to return the element that has been inserted last and is at the top without removing it. 
  • size(): This operation indicates the total number of elements the stack contains.
  • isEmpty(): This operation helps to identify if a stack is empty. 

Properties of a stack are:

  • Adding element: O(1)
  • deleting element:  O(1)
  • Accessing Time: O(n) [Worst Case]
  • Only one end allows inserting and deleting an element.

Examples of the stack include the removal of recursion. In scenarios where a word has to be reversed, or while using editors when the word that was last typed will be removed first (using an undo operation), stacks are used. If you want to try interesting data structure projects, click to read this article.

Top Data Science Skills to Learn

4. Queue

Queue is the type of data structure where the elements to be stored follow the rule of First In First Out (FIFO). The particular order is followed for performing the required operations over the elements. The difference of a queue from that of a stack lies in the removal of an element, where the most recently added object is removed first in a stack. Whereas, in the case of a queue, the element that was added first is removed first.

Following is a list of the different types of queues:

  • Input restricted queue: In this kind of queue, one can only insert inputs from one end. Deletion, however, can be done from both ends. 
  • Output restricted queue: This is just the reverse of input restricted queues. Here, the input can be taken from both ends, but deletion can only be done from one end. 
  • Circular queue: In this kind of queue, the first and the last positions are connected to one another, resulting in a circular structure. 
  • Double-ended queue: This kind of operation supports insertion and deletion from both ends. 
  • Priority queue: In this kind of queue, elements can be accessed based on priority assigned to them.

Both the end of the data structure is used for the insertion and the removal of data. The two main operations governing the structure of the queue are enqueue, and dequeue. Enqueue refers to the process where inserting an element is allowed to the collection of data and dequeue refers to the process where removal of elements is allowed, which is the first element in the queue in this case.

Properties of a queue are:

  • Inserting an element: O(1)
  • Deleting an element: O(1)
  • Accessing Time: O(n)

Other queue operations are:

  • peek() or front(): This helps to acquire the data element available at the queue’s front node without actually eliminating it. 
  • rear(): This operation returns an element at the rear without it being removed. 
  • ifNull(): Finds out if a queue is empty. 
  • ifFull(): Finds out if a queue is full. 

Have a look at this linear data structure example

Example of the queue: Similar to those queues made while waiting for the bus or anywhere, the data structure too follows the same pattern. We can imagine a person waiting for the bus and standing at the first position as the person that came to the queue first. This person will be the first one who will get onto a bus, i.e. exit the queue. Queues are applied when multiple users are sharing the same resources and they have to be served on the basis of who has come first on the server.

5. String

Although non-modifiable, Strings display characteristics similar to those that linear data structures possess. They allow operations such as searching, concatenation, and substring extraction. 

Strings are used for input/output operations, data manipulation, and text processing.

Differences Between Non-Primitive Data Structure: Linear and Non-Linear

Now that you know the fundamentals of what is linear data structure, let’s look at the differences between linear and non-linear data structures:

Linear Data Structure Non-linear Data Structure 
The elements are arranged in a sequence. The elements are arranged in the form of a hierarchy.
One can access the elements sequentially. One can access the elements randomly or based on relationships.
Efficient memory usage. Complex memory usage.
Searching and sorting operations can be performed simply. Searching and sorting operations are complex.
Examples: Array, Lined List, Stack, Queue, String Examples: Tree, Graphs

Pros and Cons of Linear Data Structures 

Some advantages and disadvantages associated with linear data structures make them suitable or unsuitable for the scenarios in which they operate. Understanding these advantages and disadvantages helps to choose the most appropriate linear data structure

The advantages of linear data structures are as follows:

  • Linear data structures help to access the elements sequentially. 

For example, arrays facilitate efficient transversal with the help of loops. This makes it suitable for tasks requiring data processing in a linear pattern. 

  • Data can be inserted or deleted efficiently. 

Arrays make it easy to access elements by index, and linked lists help insert or delete data at the beginning or end of a given list.

  • Linear data structures are easy to understand and implement. 

For instance, arrays help to store elements in a straightforward way, and linked lists use pointers that help to connect the nodes. 

  • Linear data structures offer flexibility as they allow dynamic resizing. 

This facilitates easy accommodation of the varying data amounts. It especially holds true for linked lists, which can easily grow or shrink in size by removing or adding the nodes as and when required. 

Let us now have a look at the disadvantages associated with linear data structures:  

  • During the initialization of arrays, they have a fixed size determined. 

As a result, the flexibility is limited. If the size is too small to store any additional elements, the entire array may be resized. 

  • There are insufficient search operations in linear data structures. 

For instance, in the case of linked lists and arrays, one has to traverse the elements one by one until the desired result is obtained. The time complexity of O(n) in the case of linear search may lead to inefficient results if the data set is large. 

  • Linked lists need more memory to store pointers than arrays. 

This increases the overall memory usage of the data structure and causes the efficiency to decrease. 

Read our popular Data Science Articles

Real-world Applications of Linear Data Structures 

The vast usage of linear data structures in the real world is noteworthy. Listed below are a few instances stating the use of linear data structures: 

  • Database systems: Linear data structures like linked lists and arrays are essential to database systems. Arrays help in efficient indexing and make sequential access possible. Linked lists facilitate dynamic storage and allow efficient deletion and insertion of elements. 
  • Text editors: Linear data structures incorporate features like redo and undo functionality. A stack data comes in handy in this case, as it stores the operations performed, allowing the users to revert the actions they performed initially. 
  • Browser history: The array and linked list linear data structures are used to maintain a list of all the web pages a user visits. This makes it easy for users to navigate the web pages. 
  • Task management: Queue is a linear data structure that helps in easy task management. As mentioned earlier, queues allow the tasks to be performed in a FIFO (First-In-First-Out) manner. This ensures that the oldest task is performed first. 
  • Data storage: Arrays, the simplest data structure, can store items with the same data type. Due to this reason, they find widespread usage in arranging a game’s leader board that displays the rank of the players in descending order, cell phone contacts, online ticket booking systems, and many more. 


An increase in the size of the data has necessitated the efficient use of data structures in computer programs. Data if not organized in a structured manner, the performance of tasks over the elements becomes difficult.

For a hassle-free operation, it is always important to organize it so that easy and effective operations can be carried out by computer programs. If the data elements are organized in sequential order then it is known as a linear data structure whereas if the data elements are arranged in a non-linear way, it is termed a non-linear structure. 

Wide application of data structure has been observed in machine learning languages, real-life problems, etc. People, who are dreaming to work in this field, should be able to master these concepts.

We hope this guide has been able to define linear data structure and the different types of linear data structures. 

With companies taking a data-backed approach to decision-making, the demand for data scientists who can mine and analyze huge amounts of data will likely grow by 35% from 2022 to 2032. Therefore, a specialization in data science can help you enhance your knowledge and skillsets for the ever-evolving requirements of data science occupations.

If you are want to learn more, then check out the upGrad Executive PG Programme in Data Science which provides a platform to transform you into successful data scientists. Designed for any mid-level professionals, the data science course will expose you to all the theoretical and practical knowledge required for your success. So why wait for other options, when success is just a click away. If any assistance is required, we will be happy to help you.

What is the difference between linear and non-linear data structures?

The following illustrates the significant differences between the linear and non-linear data structures:
Linear Data Structure -
1. In linear data structures, each element is linearly connected to each other having reference to the next and previous elements.
2. Implementation is quite easy as only a single level is involved.
3. Wastage of memory is much more common in linear data structures.
4. Stacks, Queues, Arrays, and Linked lists are all examples of linear data structures.
Non-Linear Data Structure -
1. In non-linear data structures, the elements are connected in a hierarchical manner.
2. Implementation is much more complex as multiple levels are involved.
3. Memory is consumed wisely and there is almost no wastage of memory.
4. Graphs and trees are examples of non-linear data structures.

In what ways are linked lists more efficient than arrays?

The following points elaborate the ways in which linked lists are much more efficient than arrays:
a. Dynamic Memory allocation
The memory of a linked list is dynamically located which means that there is no need to initialize the size and it can be expanded as well as shrink anytime without implying any exterior operation.
On the other hand, arrays are statically allocated and the size has to be initialized. Once created, the size cannot be altered.
b. Insertion and Deletion
Since a linked list is dynamically created, operations like insertion and deletion are much more convenient.
c. No memory wastage
There is no memory wastage in a linked list as all the elements are dynamically inserted. And after the deletion of an element, we can free its memory.

What are the most common operations performed in linear data structures?

The common possible operations that can be performed in all linear data structures include traversing, insertion, deletion, modification, search operation, and sort operation.
These operations are recognized by different names in different data structures. For example, the insertion and deletion operations are known as Push and Pop operations in Stack, whereas they are referred to as enqueue and dequeue operations in Queue.
There can be some other operations as well such as merging and the empty operation to check if the data structure is empty or not.

What is non linear data structure with example?

A non-linear data structure organizes data elements in a hierarchical or interconnected manner, allowing for multiple relationships. Examples include trees, such as binary trees, and graphs, where nodes can have multiple connections.

Want to share this article?

Prepare for a Career of the Future

Leave a comment

Your email address will not be published. Required fields are marked *

Our Popular Data Science Course

Get Free Consultation

Leave a comment

Your email address will not be published. Required fields are marked *

Get Free career counselling from upGrad experts!
Book a session with an industry professional today!
No Thanks
Let's do it
Get Free career counselling from upGrad experts!
Book a Session with an industry professional today!
Let's do it
No Thanks