Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Data Structures: Linked Lists

Lesson 44 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Breaking the Array Limitation

Arrays are great, but they have a huge flaw: their size is fixed. If you want to add an item to the middle of an array, you have to move every other item to make room. Linked Lists solve this.

What is a Linked List?

A linked list is a linear data structure where elements are not stored in contiguous memory. Instead, each element (called a Node) is a separate object that contains:

  1. Data: The actual information (int, string, etc.).
  2. Next: A Pointer to the next node in the line.

Visual Representation

[Data | Next] --> [Data | Next] --> [Data | NULL]

Types of Linked Lists

  1. Singly Linked List: Each node points to the next.
  2. Doubly Linked List: Each node points to both the next and the previous node. (Easier to move backwards).
  3. Circular Linked List: The last node points back to the first one.

Implementation in C

We use Structures and Dynamic Memory for this.

struct Node {
    int data;
    struct Node* next;
};

Advantages

  • Dynamic Size: Grows and shrinks as needed.
  • Easy Insertion/Deletion: Just change a few pointers; no need to shift data.

Disadvantages

  • No Random Access: To find the 100th item, you must start at the beginning and follow 99 pointers.
  • Memory Overhead: Every node needs extra memory for the pointer.
Linked lists are the foundation for more complex structures like Stacks, Queues, and even Trees. Mastering them is the key to passing technical interviews at top tech companies!