DEV Community

loading...

linked list

221910302051 profile image 221910302051 ・2 min read

A linked list is a set of data structures linked together by connections.
A Linked List is a list of objects that is made up of a series of links. Each link is connected to a different link. After series, the linked list is the most commonly used data structure. The following are some key words to know in order to grasp the idea of Linked List.
1)Link − Each link of a linked list can store a data called an element.
2)Next − Each link of a linked list contains a link to the next link called Next.
3)Linked List − A Linked List contains the connection link to the first link called First.
Linked List Representation
Linked list can be visualized as a chain of nodes, where every node points to the next node
The first connection element in a Linked List is named first.
Each connection has a data field(s) as well as a next link field.
Each connection is connected to the next link via the next link.
To indicate the end of the list, the last connection has a null link.
Types of Linked List
Following are the various types of linked list.
1)Simple Linked List − Item navigation is forward only.
2)Doubly Linked List − Items can be navigated forward and backward.
3)Circular Linked List − Last item contains link of the first element as next and the first element has a link to the last element as previous.

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.
Insertion Operation: Adding a new node to a linked list is a multi-step method. This will be taught using diagrams. Build a node with the same structure and locate the position where it should be inserted first.
Deletion Operation:
Deletion is also a more than one step process. The left (previous) node of the target node now should point to the next node of the target node-LeftNode.next −> TargetNode.next; This will remove the link that was pointing to the target node. Now, using the following code, we will remove what the target node is pointing at TargetNode.next −> NULL.
Reverse Operation:
This operation is a thorough one. We need to make the last node to be pointed by the head node and reverse the whole linked list.

Discussion (0)

Forem Open with the Forem app