A linked list is a custom data structure which can be created in C and other programming languages, designed for lists which may need to have elements added or removed from them at runtime, without knowing how big the list will need to be when it is initialised. A linked list is similar to an array, but has some important differences:
- When an array is initialised, the size of the array must be declared, and all of the memory for the array is allocated with a single command. With a linked list, memory is allocated/freed dynamically every time a new element is added or removed from the list
- Once an array is created, there is no safe and efficient way of adding or removing elements from the array, whereas a linked list is designed to have elements added and removed at runtime
- When an array is created, all the memory is allocated in a single command, and the memory addresses for each element are created next to each other, making it easy to access the element at any position in the lis