 Hello everyone, I am Mrs. Meenakshi Shrigandi from Walton Institute of Technology, Shalapur. Welcome to the video lecture on Dynamic Implementation of Singularly Link List. Learning outcome, at the end of this session, students will be able to explain the dynamic implementation of Singularly Link List using C programming. Definition of Link List A link list is a linear data structure in which the elements are not stored at contiguous memory locations. It is a data structure consisting of a collection of nodes which together represents a sequence and are linked using pointers. In this example, it shows a link list. These elements are nothing but the nodes and each node is having a different location which are linked by using pointers. Definition of node in a link list A node is an element in a link list. It consists of two parts that is a data part which contains the information and the address part which is nothing but a pointer to the next node and hence also known as the next part. This is the node representation which consists of two parts that is the data part and the address part. The data part holds the information whereas the address part holds the address of the next node. Types of link list There are three types of link list that is a Singularly Link List which contains a single link to the next node. A circular link list Here in this, the last node is not terminated by annul. Instead, a link is taken from this and it is pointed to the first node. Singularly Link List In this, it consists of two links that is one link is going to the next node and the other node is going to the previous node. Let us see the dynamic implementation of Singularly Link List. For that, we need the structure declaration. Here we use a structure to declare a node and a node contains two parts that is a data which contains the information and the next part which holds the pointer to hold the address of the next node. So your structure is declared that is a struct node in this data and the next part are declared. Let us see the operations on the link list. Here we are going to discuss some modules. Those are InsetNodeModule which is used for insertion of an element in the list. DeleteNodeModule which is used for deletion of an element from the list. SearchNodeModule which is used for search for a particular element in the list. DisplayModule which is used to display the elements in the list. Let us see the first operation that is inserting a new node. There are three ways for insertion of a node in a link list. Those are at the front of the link list after a given node at the end of the link list. Recall and answer what is the algorithm for insertion of a node in a single link list. Pause the video for some time and note down the answer in your book. This is the algorithm for insertion of a node in a single link list. This algorithm is in detail explained in my previous videos. For more details you can refer my previous videos on insertion of a node in a single link list. Here we are going to discuss the InsetNodeModule. For that we are going to declare two pointers that is new and current and a variable integer x. After that we are taking the element from the user and that is stored in x. This is the value of the new node. After this we are allocating the memory to the new node by using the malloc function. So here we are creating a new node which consists of two parts. In the first part we are storing x and in the next part of the new node we are storing null temporarily. First we are checking if the list is empty. If the list is empty then the new node becomes the first node. So for that list is assigned to new. Else indicates that the list is not empty then we check for the proper place for insertion. For that first we are initializing the pointer current which is pointing to the head node that is list. Here we are checking if the value of the new node is less than the first node then new node becomes the first node. That is the case that the new of next is now assigned to list and list is assigned to new. Else we need to traverse the linked list to find the proper place for insertion. We need to traverse till current is not equal to null and x is greater than current of next of data. If this condition becomes true then every time we need to move the current to the next node. After that is done when we reach the proper place for insertion then new of next is now assigned to current of next and current of next is now assigned to new. Let's see the deletion of node from the linked list. There are two ways for deletion of a node from the linked list. First node of the linked list or from anywhere in the linked list. Try to recall and answer what is the algorithm for deletion of a node from a single linked list. Pause the video for some time and note down the answer in your book. This is the algorithm for deletion of a node from a single linked list. This algorithm is already explained in detail in my previous video. For more details you can refer my previous video on deletion of node from single linked list. Here we are going to discuss about delete node module. For that again we are going to declare two pointers that is trail and current and a variable x. First we are collecting the value of x from the user that is representing the value of the node to be deleted. First we are checking if the list is equal to null. If the linked list is empty then no node to delete. In that case we are only printing a message that no node to delete. Else indicates that the linked list is not empty for that we need to traverse the linked list. First we are initializing the pointer. Trail is assigned to null initially and current is pointing to the head node that is the list. And we need to traverse the linked list till we get the node to be deleted. That is still this condition somewhere that is current is not equal to null and current of data is not equal to x. If this condition becomes true every time we need to move trail to the current place and current is moved to the next node. After traversing if current is not equal to null this indicates that the node to be deleted is present in the list. Trail is equal to null. This condition indicates that the node to be deleted is the first node. If that is the case then only we need to make list equal to list of next. Else indicates that the node to be deleted is in between two nodes. For that only we need to make trail of next equal to current of next. Else indicates that current is equal to null after traversing the linked list. This indicates that the node to be deleted is not present in the linked list. Try to think and answer what is the algorithm for searching a particular node from a single linked list. Pause the video for some time and note down the answer in your book. For searching a particular element in a single linked list. Initialize x with value of the node to be searched. Initialize the current pointer to the head of the list. Travels the list till we reach the node to be searched or till we reach the end of the list. If current is equal to null then print node to be searched doesn't exist. Else print node is found. Here we are going to discuss the search node module. Again here we are going to declare a dummy pointer called as current and a variable x. First we are checking if the list is equal to null which indicates that the list is empty. If the list is empty then no node to search. Then print that no node to search and return back. Else indicates that the list is not empty. If the list is not empty then we need to traverse the linked list to search the required node. For that we are initializing the pointer current to list and we are taking the value from the user in x that is the node to be searched. And we are traversing the linked list till current is not equal to null and current of data is not equal to x. That is we need to traverse the linked list till the node to be searched is found or current is not equal to null. If this condition becomes true every time current is moved to the next node. If current is equal to null this indicates that after traversing if current is null the node to be searched is not found. Then in that case only print the message that node is not found. Else indicates that after traversing if current is not null the node to be searched is found. Then here we are displaying the message as node has found. Then the last module is the display module. In this we are again declaring our temporary pointer called as current. And first we are checking if the list is empty. If list is empty then no node to display. Here we are only displaying the message as list is empty and written back. Else indicates that the list is not empty and we need to traverse the list to display the nodes. Here we are initializing the pointer current to the list and we are traversing the linked list till current is not equal to null. Traverse the list and display the data pointed by current. Repeat this till current is not equal to null. So if this condition current is not equal to null this condition if it becomes true then every time we need to print the data which is pointed to by the current and after that is done current is moved to the next node. This process is repeated till current is not equal to null. Here it complete all the modules for the dynamic implementation of singly linked list. These are my references. Thank you.