Back to Cosmos

Linked List

code/data_structures/src/list/README.md

latest1.8 KB
Original Source

Linked List

A linked list is a data structure containing a series of data that's linked together. Each node of a linked list contains a piece of data and a link to the next node, as shown in the diagram below:

Image credit: By Lasindi - Own work, Public Domain, https://commons.wikimedia.org/w/index.php?curid=2245162

Types of Linked Lists

There are several types of linked lists. The most common ones are:

Singly linked list

The simplest type. Each node has a data field and a link to the next node, with the last node's link being empty or pointing to null.

Double linked list

Image credit: By Lasindi, Public Domain, https://commons.wikimedia.org/wiki/File:Doubly-linked-list.svg

Each node of a doubly linked list contains, in addition to the data field and a link to the next code, a link to the previous node.

Circularly linked list

Image credit: By Lasindi, Public Domain, https://commons.wikimedia.org/wiki/File:Circularly-linked-list.svg

A singly linked list, except that the last item links back to the first item, as opposed to a singly linked list which links to nothing or null.

Sources and more detailed information:


<p align="center"> A massive collaborative effort by <a href="https://github.com/OpenGenus/cosmos">OpenGenus Foundation</a> </p>