0% found this document useful (0 votes)
6 views4 pages

What is Linked List

A linked list is a linear data structure consisting of nodes connected by pointers, where each node contains data and a pointer to the next node. There are various types of linked lists, including singly linked lists, doubly linked lists, and circular linked lists, each with different traversal capabilities. Basic operations on linked lists include insertion, deletion, searching, and traversal, which can be performed at various positions within the list.

Uploaded by

amalambikaschool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

What is Linked List

A linked list is a linear data structure consisting of nodes connected by pointers, where each node contains data and a pointer to the next node. There are various types of linked lists, including singly linked lists, doubly linked lists, and circular linked lists, each with different traversal capabilities. Basic operations on linked lists include insertion, deletion, searching, and traversal, which can be performed at various positions within the list.

Uploaded by

amalambikaschool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

What is Linked List?

A linked list is a linear data structure which can store a collection of "nodes" connected
together via links i.e. pointers. Linked lists nodes are not stored at a contiguous location,
rather they are linked using pointers to the different memory locations. A node consists of
the data value and a pointer to the address of the next node within the linked list.

A linked list starts with a head node which points to the first node. Every node consists of
data which holds the actual data (value) associated with the node and a next pointer which
holds the memory address of the next node in the linked list. The last node is called the tail
node in the list which points to null indicating the end of the list.

Types of Linked List


Following are the various types of linked list.

1. Singly Linked Lists


Singly linked lists contain two "buckets" in one node; one bucket holds the data and the
other bucket holds the address of the next node of the list. Traversals can be done in one
direction only as there is only a single link between two nodes of the same list.

2. Doubly Linked Lists


Doubly Linked Lists contain three "buckets" in one node; one bucket holds the data and the
other buckets hold the addresses of the previous and next nodes in the list. The list is
traversed twice as the nodes in the list are connected to each other from both sides.

3. Circular Linked Lists


Circular linked lists can exist in both singly linked list and doubly linked list.
Since the last node and the first node of the circular linked list are connected, the traversal
in this linked list will go on forever until it is broken.
Basic Operations in Linked List
The basic operations in the linked lists are insertion, deletion, searching, display, and
deleting an element at a given key. These operations are performed on Singly Linked Lists as
given below −
 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 at a Given Position


In this operation, we are adding an element at any position within the
list.
Algorithm
 1. START
 2. Create a new node and assign data to it
 3. Iterate until the node at position is found
 4. Point first to new first node
 5. END
Insertion at Ending
In this operation, we are adding an element at the ending of the list.
 Algorithm
 1. START
 2. Create a new node and assign the data
 3. Find the last node
 4. Point the last node to new node
 5. END
Insertion at Beginning
In this operation, we are adding an element at the beginning of the list.
 Algorithm
 1. START
 2. Create a node to store the data
 3. Check if the list is empty
 4. If the list is empty, add the data to the node and
 assign the head pointer to it.
 5. If the list is not empty, add the data to a node and link to the
 current head. Assign the head to the newly added node.
 6. END
Deletion at Beginning
In this deletion operation of the linked, we are deleting an element from the beginning of
the list. For this, we point the head to the second node.
Algorithm
1. START
2. Assign the head pointer to the next node in the list
3. END
Deletion at Ending
In this deletion operation of the linked, we are deleting an element from the ending of the
list.
Algorithm
1. START
2. Iterate until you find the second last element in the list.
3. Assign NULL to the second last element in the list.
4. END
Deletion at a Given Position
In this deletion operation of the linked, we are deleting an element at any position of the
list.
Algorithm
1. START
2. Iterate until find the current node at position in the list.
3. Assign the adjacent node of current node in the list
to its previous node.
4. END
Reversal Operation
Algorithm
Step by step process to reverse a linked list is as follows −
1. START
2. We use three pointers to perform the reversing:
prev, next, head.
3. Point the current node to head and assign its next value to
the prev node.
4. Iteratively repeat the step 3 for all the nodes in the list.
5. Assign head to the prev node.
Search Operation
Searching for an element in the list using a key element. This operation is done in the
same way as array search; comparing every element in the list with the key element
given.
Algorithm
1 START
2 If the list is not empty, iteratively check if the list
contains the key
3 If the key element is not present in the list, unsuccessful
search
4 END
Traversal Operation
The traversal operation walks through all the elements of the list in an order and displays
the elements in that order.
Algorithm
1. START
2. While the list is not empty and did not reach the end of the list,
print the data in each node
3. END

You might also like