loading

DSA Linked Lists

As the name suggests, a linked list is one in which the nodes are connected to one another. Every node has a pointer and some data on it. Each node indicates the location of the subsequent node in the memory, which is how they are connected.

Linked Lists

A linked list is made up of nodes that contain data of some kind and a link, or pointer, pointing to the node after them.

Dsa Linked Lists -

One major advantage of linked lists is that nodes can be stored anywhere in memory that has empty space; unlike arrays, which need nodes to be stored consecutively after one another, linked lists do not require this. The fact that the remaining nodes in the list do not need to be moved when new or removed from the list is another great feature of linked lists.

Linked Lists vs Arrays

Maybe comparing linked lists and arrays can help you comprehend linked lists the best.

Unlike arrays, which are pre-existing data structures that we can utilize in the computer language, linked lists are linear data structures that we create ourselves and are made up of nodes.

While array elements do not have to store links to other elements, nodes in a linked list do.

Note: We’ll go into more detail on linked lists and arrays’ memory storage on the following page.

To help you better grasp linked lists, the table below contrasts them with arrays.

 ArraysLinked Lists
An existing data structure in the programming languageYesNo
Fixed size in memoryYesNo
Elements, or nodes, are stored right after each other in memory (contiguously)YesNo
Memory usage is low
(each node only contains data, no links to other nodes)
YesNo
Elements, or nodes, can be accessed directly (random access)YesNo
Elements, or nodes, can be inserted or deleted in constant time, no shifting operations in memory needed.NoYes

The following page will concentrate on the memory storage methods of arrays and linked lists in order to further clarify these distinctions.

Share this Doc

DSA Linked Lists

Or copy link

Explore Topic