+ 1
Linked list
What is LINKED LIST and how does it works? Please explain with most understandable explaination. And show me the code.Thanks.
1 Answer
+ 6
"""
The linked list data structure is often used to implement other data structures.
A linked list is a sequence of nodes where each node stores its own data and a pointer (address) to the location of the next node.
One node links to another forming what can be thought of as a linked chain: The last item in the list has a link to NULL, indicating the end of the chain.
Advantages:
Although a linked list is similar to an array, it is not restricted to a declared number of elements. Additionally, unlike an array which stores data contiguously in memory or on disk, a linked list can easily insert or remove elements without reallocation or reorganization of the entire structure because the data items need not be stored contiguously.
Linked List Drawbacks:
1) Random access is not allowed. We must access nodes sequentially starting from the first one. Therefore, we cannot do a binary search on a linked list.
2) Extra memory space for a link is required for each element of the list.
"""
~Lesson Factory