 Myself Rohit Kumar Rudrapa Vakhtarikar, working as an assistant professor at Computer Science and Engineering Department at Valsitra Technology, Solapur. Today, we are going to see how to insert an element at a specific position in a list using STL. Learning outcomes, at the end of the session, students will be able to perform the insertion of an element at a specific position in a list using the STL. So, before this video, we have already seen one video based on the list using STL. So, in this list, we have performed many operations like retrieving the first element, last element and even merging the different list in a list STL. So, now, but in list, they have not given any function which allows us to insert a specific element at a specific position in our list. So, for that here, we need to implement our own method which is going to take the input from the user as in which position you are going to insert the element. So, there will be the two things you have to take from the user. That is one is the position or the index and another one is the element where actually you are going to insert that particular element. So, let us see the implementation, how we are going to done that one. So, see here, first of all, we need to include the list because we are going to perform the operations on the list, fine. And one more important thing is about iterator header file. So, this iterator header file allows us to iterate over the list, fine. We are iterating over the list. So, now, the main objective of our video is what? Insert the element at a specific position. So, first what we will do? Let us take the two input from the user that is the position, where do you want to actually insert the element and another one is the actual element which you want to insert, fine. So, after that, we need to have one list which has hold some values, right. So, now, here this list header files, one instance we have created list one of the integer data type which is going to store these elements. Here by default we have placed 1, 2, 3, 4, 5 and 6, 6 elements here, fine. So, here after that we are trying to display the list elements for that here again we have written on show list method. This show list has one argument called the list one. So, this list one is a reference or the object of this list type, fine. So, I am sending this list one to the show list function, right. So, let us see here the show list function or method. So, wide show list has one argument of the list type. Its name is L1. So, here we need to initiate or initialize our iterator on which list it is going to be work out, okay. So, now here we will have the iterator it which is going to iterate over the list which has a integer variables, fine. Now, here we need to write the for loop which travels over the list. So, now let us initialize this iterator it is equals to L1.begin. Means this it initially going to point on the list begin. We have already seen this begin in our previous video, right. Then till where it is going to be iterate till we will got the end of the list that is L1.end and then iterator plus plus, right. So, now by this line it is going to iterate the iterator on a list till we will get the end of the list, fine. So, now after that what we are going to do? We are simply going to display the iterator values, right. So, now that particular list element is going to be stored in this it that is the reference of this iterator and we have stored there. So, now this iterator is going to display this elements, fine. So, if you look at the code till here we got the only element from the list. So, let us see here, list 1 will have 1, 2, 3, 4, 5, 6 these are the 6 elements will have in our list, ok. So, now come to the main objective. Now here what we are going to do? We want to perform the insertion at a specific position. So, here we need to take the input from the user that is on which position is going to store the or the inside the element. So, for that we are going to use this end position here. So, now user will enter the position and it is going to be stored in this POS, ok fine. So, obviously in this iterator directly we are not going to access that particular position, ok. So, how we are going to do then? Here we need to write one more iterator over the list, fine. So, see here this is the very important steps. So, here the list of integers where iterator sp this is sp that is stack pointer or list pointer whatever you can say that is going to be point on a begin, see here, right. Means sp is a pointer which is pointed on this list 1 dot begin, begin of the pointer. So, what we need to do then? So, now we have already taken the position from the user on which position we are going to store that is first, second, third, fourth, right. So, here we need to iterate or increment the pointer sp pointer till the specified position, right. It means integer i is equals to 0, i is less than POS minus 1 that is entered position minus 1 because it is start from the 0, 1, 2, 3, right. So, here we are dealing with the directly 1, 2, 3, 4, fine we will start from the 1. That is why what we have done position minus 1 then i plus plus. So, it is going to increment the pointer sp pointer and now what we will do? Take the input from the user, right. That is what? Enter element is going to enter the element value and now here there is a one more function called the insert. That insert allows us to insert the element, right, insert the element. So, now what we will do that insert the element into the sp position, right. So, this is sp position and specific one element, which element. So, now again what we are going to do? Simply we are going to print the values, ok. So, let us see how it is going to be work. So, initially in my list I will have 1, 2, 3, 4, 5 and 6 element. So, let us say I want to insert the element at the second position, fine. That means 1, 2. On this position I want to insert, right. So, position I have given the 2 and enter the element, right, 200. So, see here what we have done. On the first it is 1 and the second position here we will have the 2, but on the second position we are going to insert the 200. So, now here it will become the 200, right. And we are just forwarding these pointers to the next elements in our list, ok. So, let us say now I want to insert the element at a fourth position, fine. Let us say I want to insert the 400. So, where is the fourth position that is this one, right. So, what we are expecting output 1, 2, 3, 400, 4, 5 and 6, fine. Let us see what is the output, see here, 1, 2, 3, then 400, right. On the fourth position we have inserted the element and now this 4, 5, 6 has been shifted, right. It means like in the linked list what we are going to do is we are going to create one node that new node we are going to place into the list, right. So, there is no need to perform the right shift of the 4, 5, 6 elements, right. Because this is the list, that is why we are going to prefer the list over the array, fine. So, think and write. Is it possible to delete any element from the list from any position? It means like currently we are going to accessing the element, right, from the specific position. I am going to retrieving the element. So, can we delete that a particular specific element from the list? Yes, think, yes, that is possible. We can perform this operation by simply traversing the pointer. We will traverse the pointer over there and we can delete that particular element. So, we can write our own delete method also, right, which we have written now. Hope everyone is getting this concept. References are Obvious Learning Programming with C++ 6th Edition by Ibal Guru Swami. Thank you.