 Today we will see the topic how to insert a node at the end in the W linked list. In the previous lecture or in the previous video session, we have seen how to insert a node at the beginning of the W linked list. As we know that the W linked list or the objective or the learning outcome of today's student will be able to explain operation of inserting a node at the end of the W linked list. This is an example of a W linked list in which we observe that there are three nodes. The three nodes are held by the starting pointer that is called the head which stores the address of the first node. And this particular node contains three parts. This particular part is called the address part, the middle part is called the data part and the last part is called the address part. The types of insertion as we have seen, there are three types of insertion. One is insertion, the element at the beginning, second insertion of an element at the end and insertion of an element at the specific location. Today we will focus on insertion of an element at the end of the list. The algorithm, first of all, we will see what is the algorithm, how to insert a node at the end of the W linked list. The first step, we have to create a new node in which we need to read the data in the data part which is to be inserted in the node and the address part that is the right part of the data part that is called the new node next that has to be made null because we want to insert this particular node at the end. So the last part will be always the last nodes, right part of the data that is next pointer will contain null. Then the second step is that first of all we need to check whether the list is empty or not. If list is empty, then what to do? If list is not empty, then what to do? If list is empty, how to check? If head is equal to null, if head pointer does not contain any nodes, means head is pointing to null, then it is called as a empty list. If it is so, whatever the node we are going to insert, that will be the first node. So in that case, what we have to do? In the third step, if it is empty, then we have to assign null value that is new node previous means the left part of the data part of the node that is previous pointer should be made as a null. And we have to assign, since initially head was null, now we have to give the address of or give the value of new node to the head, so that head will hold the address of this particular first node. Fourth step, if suppose list is not empty, suppose there are more than one nodes are there in the list, then what we have to do? We have to reach to the last node of the list, last node of the list. For that, we need to define one temporary pointer and we have to assign the value of head to that particular temp pointer means it will now hold the address of the first node. Now we have to reach this temp pointer till the last node means we have to keep moving the temp pointer to the next node until it reaches to the last node in the list. The last sixth first step, once you reach the last node, then we have created node that node is hold by new node, that node is hold by new node, node so that what we have to do? We have to assign new node to temp next and temp to new node previous, we will see diagrammatically step by step in the next slides. First step was create a new node, so this is a node is created, the address of the node say for example 100 at the location 100, for example it is say 100 and this is hold by the pointer called as a new node. So new node are presently holding this 100 value and initially the value of head is null. Now the code for that, for declaring a structure we are declaring three variables, integer data, so integer data this middle part will store the data, integer value, struct node previous, so this is the data part which will hold the address of the previous node and struct node next, so this right part of the data part will be holding the address of the next node. Then we declare new node pointer and head pointer which will assign the value null, initially head is equal to null means initially there are no nodes in the list, no connection between head pointer and the node. So initially node is we are created node, in the next part here the node is created with a malloc function, now here read the data from the user which is to be inserted in the node and assign null value to the new node next. So initially head is null, this part as it is now what we will do, we will read the data and assign to the data part that is 10 is red and kept in the middle part that is data part, then what we have to do, we have to new node next means this particular part should be made as a null, so this is made as null, the code for this particular steps is by print up and scan up we are reading the data and we are assigning the null value to the new node next, so this part is made null, so new node is now inserted data, now check whether the list is empty or not initially, yes head is empty, the value of head is null, if it is empty then this will be the first load. So what to do, we have read in the previous statements that data is red, this right part is new node next is made as a null, now new node previous, this particular part will hold the, which will not contain any node because this is the first node, so this will be made as a null and head should be connected to this node, this is made null and head is now connected to null, the code for this particular part is if head is equal to null means we are checking list is empty, if so the new node previous this particular part is made null and head it was initially null, now it has made, it has given the address of this particular node that is 100 will be stored over here. In the next slide if it is not empty means few nodes are there in the list, then we need to define a node pointer, suppose the list is contains 1 and 2 nodes are there, one is containing 30 and second is containing 20 and head is assigned to the first node, now we need to first of all declare a time pointer, we will declare a time pointer and assign it to the first node that is we will assign the value of head to the time pointer, so this is how node time pointer is created, the value of 100 is assigned in a time pointer which will hold the address of the first node, now we will move this time pointer till it reaches to the temp next, temp next, now temp next here it is 200 that is the address of this particular node, this 100 is indicating that it is the address of the first node and 200 is the address of this second node and this one is the address of this particular new node, this 100, 200, 300 we have taken for the sake of understanding, now keep moving the temp pointer till it reaches to the temp next, means we have to move temp pointer till it reaches this particular part as then, now this particular first node does not contain null part in the temp next, so this is having actually 200, so we will move temp is equal to temp next, so temp will now come over here, it will come over here, now whether temp next, now temp previous is 100, temp data is 20 and temp next is null, means this is the last node of the list, once you reach this particular list then what we have to do, we have to whatever the new node is created over here, whatever the new node is created with the value temp and the next part is null, we have to connect, we have to give the connection between second node and this created node, we have to connect here in the null part, in the null part, we have to give the address of this new node, so that 300 will come over here and this new node previous again will be pointing to the previous node that is 200 will be stored over here, for that if it is not else part, else part is what if it is not empty, struct node temp is created and we have, temp is created and we have assigned the value of head to this temp, while temp next is not equal to null, means to traverse temp from first node to till it reaches to the last node, this if it is not null then we have to move temp one node to second node, temp equal to temp next, now assign new node to temp next, now this value, this 300 should be assigned to over here, temp, so this is what, 300 will be stored new temp next and new node previous and temp, temp means this is 100 value should be assigned to temp previous, new node previous, now this is a code which will explain us, first of all the new node is assigned to temp next that is 300, the new node previous, this part particular part where the address of temp that is 100 will be stored over here, so that these two are connected to each other, what is the difference between singly linked list and doubly linked list, please take a pause and give the answer, the answer is singly linked list traverse in forward direction whereas the doubly linked list traverse in both the directions, this is the code, these are the references, thank you.