Skip to content

Latest commit

 

History

History

Linked List

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Linked Lists

Linked List

Overview

A linked list is a linear data structure where each element is a separate object called a "node." Each node contains a reference (or link) to the next node in the sequence. Linked lists are dynamic and can grow and shrink in size by allocating and deallocating memory as needed.

Table of Contents

Introduction

A linked list is a linear data structure which is a collection of multiple nodes. Each node contains two parts: a data part and a next part, which is a pointer that contains the address of the next node. Linked lists are dynamic and can grow and shrink in size by allocating and deallocating memory as needed.

Types of Linked Lists

  • Singly Linked List: Each node contains a single link to the next node.
  • Doubly Linked List: Each node contains links to both the next and previous nodes.
  • Circular Linked List: The last node in the list points back to the first node, forming a circular structure.

Operations

Common operations performed on linked lists include:

  • Insertion: Adding a new node at the beginning, end, or middle of the list.
  • Deletion: Removing a node from the list.
  • Traversal: Visiting each node in the list.
  • Search: Finding a node with a specific value.

Examples

  • Reverse a Linked List: Reverse the order of nodes in a linked list.
  • Detect a Cycle: Check if the linked list contains a cycle (loop).