hamburger

Difference Between Array and Linked List

By BYJU'S Exam Prep

Updated on: September 25th, 2023

The Difference between Array and Linked List is that the array uses contiguous memory locations, whereas the linked list uses non-contiguous memory locations. Array and Linked List are linear data structures that store and organize data. We use linear data structures like an array and a linked list for sorting the data. These two data structures are widely used in the sorting of data. 

We use arrays and linked lists to store many homogenous data. In this article, we will briefly learn the difference between array and linked list, along with their description. 

Formulas for GATE Computer Science Engineering – Programming & Data Structures

Difference Between Array and Linked List

The difference between array and linked list is that an array provides random access to the data elements because we use an array index to access array elements. In contrast, a linked list does not provide random access to elements.

Key Differences Between Array and Linked List

Array

Linked List

It is a collection of elements of similar data types.

It is a collection of entities called nodes.

They use contiguous memory locations.

They use non-contiguous memory locations.

Works with static memory.

Works with dynamic memory.

Random access is possible.

Only sequential access is possible.

Insertion and deletion take more time.

Insertion and deletion take less time.

Memory allocated at compile time.

Memory allocated at run time.

What is an Array?

An array is a collection of similar types of data elements. These data elements have the same data type. An element in an array is referred to as an array element. Array elements are stored in consecutive memory locations. After the array, the next linear data structure that we learn is a linked list.

Difference between Array and Linked List PDF

An index references each array element. Generally, the array index starts from zero up to the length -1. That is, if we have an array of length, say n=10, then the array index will start from 0 up to 9, as shown in the below figure:

What

What is a Linked List?

A linked list is a linear collection of data elements. Data elements in a linked list are called nodes. A linked list can be used to implement other data structures such as stack, queue, and other variations of stack and queue.

A node contains two parts: a data part and a pointer to the next node. The left part of the node is used to store the data, which may be an integer or a character, and the right part of the node is used to store the pointer to the next node in sequence (address of the next node to be accessed). We can learn about the difference between List and Tuple to know more about a linked list. The last node of the linked list contains Null in the pointer part, which marks the end of the list. A linked list is shown in the figure:

What

Important GATE Topics
Difference between crystalline and amorphous solids Difference Between Von Neumann and Harvard Architecture
Difference between DBMS and RDBMS Difference between desktops and laptops
Difference between DDL and DML Difference Between Modem and Router
Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium