A linked list is a collection of objects known as nodes. Each node is connected to the next node with a link, which is nothing but an object reference. If we consider the following image, each box represents a node. The arrow indicates the link between the nodes. This is an example of a singly linked list. The last node contains the next link of a NULL, so that it marks the end of the list:
A node is an object, meaning it can store any data type as simple as a string, integer, or float, or complex, such as an array, array of arrays, objects, or object arrays. We can store anything as per our need.
We can also perform a wide variety of operations on a linked list, such as the following ones:
- Checking whether the list is empty
- Displaying all items in the list
- Searching an item in the list
- Getting the size of the list
- Inserting a new item at the beginning...