Linked List in Data Structure
A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. A linked List is a sequence of links that contain items. Each link contains a connection to another link. The Linked list is the second most used data structure after the array. The following are important terms to understand the concepts of Linked List.
A linked list consists of a data element known as a node. And each node consists of two fields: one field has data, and in the second field, the node has an address that keeps a reference to the next node. In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes that together represent a sequence.
Linked List in Data Structure – Types of Linked Lists
- Simple Linked List − Item Navigation is forward only.
- Doubly Linked List − Items can be navigated forward and backward way.
- Circular Linked List − Last item contains a link to the first element as the next and the first element has a link to the last element as prev.
Basic Operations
Following are the basic operations supported by a list.
- Insertion − Adds an element at the beginning of the list.
- Deletion − Deletes an element at the beginning of the list.
- Display − Displays the complete list.
- Search − Searches an element using the given key.
- Delete − Deletes an element using the given key.
Advantages of Linked List
- Dynamic Size
- It is easy to add/remove/change elements
- Elements of linked lists are flexible, they can be primary data types or user-defined data types
The disadvantage of the Linked List
- Random access is not allowed. We have to access elements sequentially starting from the first node.
- So we cannot do a binary search with linked lists 2. It cannot be easily sorted
- We must traverse 1/2 the list on average to access any element
- More complex to create than an array 5. Extra memory space for a pointer is required with each element of the list
Linked List in Data Structure
You can download the Linked List in Data Structure PDF using the link given below.