-
Notifications
You must be signed in to change notification settings - Fork 0
Linked List
Sgt. Mahdi edited this page Apr 11, 2025
·
4 revisions
It's a way to store a collection of data like numbers, where each data is part of a chain. instead of being stored one after another in the memory, each item is placed in a node located at a diffrent memory address (Unlike Array it's not contiguous)
There are two types of linked list:
- Singly Linked List
- Doubly Linked List
It's an object which holds data and addresses.
There are two types of nodes:
- Singly: this type stores two things
Data
Address of the next node
- Doubly: this type stores three things
Data
Address of the next node
address of the previous node
When you add new data to a linked list, you're creating a new node and linking it into the chain.
- Create a new Node.
- Set the new node’s pointer to the next node (or to null if it's going at the end)
- Update the previous node's pointer to link to the new node.
You can see how to code this process in My Custom Linked List Class
This file you'll see how to code doubly linked list: