2 min read

Linked List in Data Structures

Llinked Lists should be used for large lists of data where the total number of items in the list is changing.
Linked List in Data Structures

A data structure is a particular way of organizing data in a computer so that it can be used effectively.

For example, we can store a list of items having the same data-type using the array data structure.


What is Linked List?

Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at a contiguous location; the elements are linked using pointers.


Why Linked List?

1) The size of the arrays is fixed: So we must know the upper limit on the number of elements in advance.
2) Inserting a new element in an array of elements is expensive because the room has to be created for the new elements and to create room existing elements have to be shifted.
For example, in a system, if we maintain a sorted list of IDs in an array id[].
id[] = [1000, 1010, 1050, 2000, 2040].

So, addition, updation, deletion  is difficult And if we want to insert a new ID 1005, then to maintain the sorted order, we have to move all the elements after 1000 and for deleting also to delete 1010 in id[], everything after 1010 has to be moved.

Advantages over arrays
1) Dynamic size
2) Ease of insertion/deletion

1) Random access is not allowed. So we cannot do binary search with linked lists efficiently with its default implementation.
2) Extra memory space for a pointer is required with each element of the list.
3) Not cache friendly. Since array elements are contiguous locations, there is locality of reference which is not there in case of linked lists.

GeeksforGeeks | A computer science portal for geeks
A computer science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

#DataStructures #Arrays #LinkedList #Programming #Probyto #ProbytoAI

Subscribe and follow us for latest news in Data Science, Machine learning, technology and stay updated!
Facebook: https://facebook.com/probyto
Twitter: https://twitter.com/probyto
LinkedIn: https://linkedin.com/company/probyto
Instagram: https://instagram.com/probyto