kids encyclopedia robot

Linked list facts for kids

Kids Encyclopedia Facts

A linked list is a special way to store information in computer science. Imagine you have a bunch of items, like different toys, but they aren't lined up in a box. Instead, each toy has a secret note that tells you exactly where to find the next toy. This way, even if the toys are scattered all over the room, you can still find them one after another by following the notes.

In a linked list, each piece of information is called a node. Each node holds two main things:

  • The actual data (like the toy itself).
  • A "link" or "pointer" that points to the next node in the list (like the secret note).

The very first node is called the head of the list. The last node has a special link that points to nothing, showing that it's the end of the list. This is a very flexible way to store data because you can easily add or remove items without having to rearrange everything else.

Types of Linked Lists

There are a few different kinds of linked lists, each with its own special features.

Singly Linked List

Singly-linked-list
A singly linked list. Each box is a node, and the arrows show the links to the next node.

A singly linked list is the simplest type. In this list, each node only points forward to the next node. Think of it like a one-way street. You can easily go from the start to the end, but you can't go backward from a node to the one before it without starting over from the beginning.

Each node in a singly linked list has two parts:

  • The data it holds.
  • A link to the next node.

Doubly Linked List

Doubly-linked-list
A doubly linked list. Each node has links pointing both forward and backward.

A doubly linked list is more flexible than a singly linked list. In this type, each node has two links:

  • One link points forward to the next node (like in a singly linked list).
  • Another link points backward to the previous node.

This is like a two-way street! You can move forward through the list, and you can also easily move backward. This makes it easier to add or remove items from the middle of the list.

Circular Linked List

Circularly-linked-list
A circular linked list. The last node links back to the first node, forming a loop.

A circular linked list is a bit different. Instead of the last node pointing to nothing (to mark the end), it points back to the very first node in the list. This creates a continuous loop.

Imagine a Ferris wheel where the last car connects back to the first car. There's no real "end" to the list, as you can keep going around and around. Circular linked lists are useful in situations where you want to cycle through items continuously, like in a game where players take turns.

See also

Kids robot.svg In Spanish: Lista enlazada para niños

kids search engine
Linked list Facts for Kids. Kiddle Encyclopedia.