A double linked list is a data structure where each node contains three components: a value field, a next pointer to the subsequent node, and a previous pointer to the preceding node, enabling bidirectional traversal. To insert a new node at the beginning, create a new node, set its next pointer to the current head, set its previous pointer to null, update the head to point to the new node, and update the previous pointer of the old head to point to the new node. To insert at the end, use the last pointer to access the final node, set the new node's next pointer to null, set its previous pointer to the current last node, update the last node's next pointer to the new node, and update the last pointer to the new node. To delete a node, first locate it by traversing from the head, then update the previous node's next pointer to point to the target node's next node, update the next node's previous pointer to point to the target node's previous node, and free the target node's memory.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
DSA | CSE | Class-3 | SNZ | University of ScholarsAdded:
So if I want to delete this note, what do I simply need to do to delete this note? The link to this note should be removed.
This is our story. So what should I simply do? Instead of linking this note to this one, you can just link it to this one.
And it won't be enough to fill this memory later.
So this is what we are doing here, see if it is the first list again. I took two nodes.
I need two notes on this. Because I have to understand until I can figure out this certain value.
Now suppose I have found this node.
Now that I have it, I do n't have to connect the previous one to the next one. So that's it, I need a pointer to refer to the previous one.
And here we need a car pointer.
So who has one and who has two?
Now, if you want to do this in the code before you search, you'll have to search until you find the car. The value of the car is not equal to the value of the car. If I say that this note with the number one will also delete the note that is in it, then you don't have to search for the one.
First of all, you will find it in the list.
Okay, after you get it, you exit the loop. Before you exit the loop, your current is already set to one. The pip is set to two. So you don't understand. Yes, behind you, behind you, you understand.
But you can see from your face that you understand.
Okay, if you don't understand, tell me yourself. I'll read everyone's faces. How did you say that? Look at him. Who said yes? I don't understand. Yes, I'm saying that. We're catching up. Okay, let's see what I'll do. This next has to update this value because it pointed to it before, now it points to me, so what should I do, next in the current, which the current next is pointing to, prevent next, then automatically delete this data a little while ago, but now this link is done, after this link is done, what should I do, free the car, if I free it, will the car be automatically deleted and deleted if there is no data or no notice, then shouldn't this link also be there? I understand that deleting it is understandable.
I read the three divisions today or if anyone has any problems with insertion, now we see the double list.
Well, you can see the double links here in the picture.
It's already back and forth.
A little while ago, my link had a problem, that is, every time I went to work with the previous node, I had to keep a separate pointer for my previous load, through which I would connect to the next or the work.
I would have done it, but there was simply no way to go back.
I could work even with a note in my bank. But there was no way for me to move backwards.
What about double English? Now I can move in both directions, in front of me and behind me.
So what do I need for this? You need to create a node that is also connected to the node in front. It will also be connected to the back node.
So if I want to connect to two nodes, I need to have two pointers.
One is the previous pointer and the other is the next pointer. Isn't that right? So there will be three slots in it. One is Value, one is Next, and the other is Previous.
Next will point to the next node and Previous will point to the previous node. There are three of them.
This will happen with this and that is okay with this. I can go forward or backward if I want. I can also come from behind to the front.
So if I want to insert first, meaning at the beginning, if I want to insert at the beginning of the list, how can I do that?
Look at this, the first note has been made.
Here are two pointers. One is a P pointer and the other is a next pointer. And lastly, we represent the place where the value is stored with a value variable.
Well, look here, last time we just had a head pointer, now we can come to the front from behind. So we already know the name of the last one.
What is the last note of the last called? Last say. Isn't that right? It is called last note or table note.
So, since we have this scope, I'll come first from last. So the last one needs to be scored with something. So I'm going to point to the code of the last one, which is the pointer named last. I'll insert it at the beginning now.
I need data to insert. So I gave you the data.
I bought a new item.
Okay, this is the last one.
Okay, now look, I took a new item.
Since I want to insert a new node, I have to create the node first.
So I made the note and dynamically memorized it. So, who is this thing that happened to me? So, I want to put the number five in the value of this node, which is the value of the node.
So I put five in it.
Here you see Value equals Data. So I had five in the data.
What is the five? Isn't this node's val position set? It's sitting. Okay. Now, the next pointer and the print pointer of this is next and this is print.
I have to work between these two.
First, I am checking whether this is the first node or not. It could not be that there is no item in the node, as you say, but I am inserting the first node. It could not be that.
So if the head was already pointed to null, that means the list does not exist now. The first note I am going to give in the list, then if I give the first note, my head will point to the new item.
Of course, it is not because since there are no other notes, the head will point to the new one that I created.
Look at the next of the new item. If I had done that, the previous would have been null, the next would have been null, so I would not have done the next of the head. I would not have done the last head, sorry, I would not have done the previous of the head, and since this is the beginning and this is the end. In Tarane, the only thing that would be the last in the list would not be the last. It would point to this.
But now I assume it was easy.
But what if I already have a list?
Now tell me, it will grab this place. It means that the head is pointed to. It will point to the next item of the new item. It will point to the head. It is pointing My head is pointed towards the frustrator on the so-existing list.
So what do I do in the winter? I will point the next of the new item to where the head is pointing towards this frost.
Give it the same way, the head of the head is now pointing this way. Let 's move the head now. I will start pointing the prep pointer on the saw head to the drain. So instead of pointing to the new item, I'll now point the header to the new item. Okay, the pre pointer of the new item is to be pointed to null. Now I have a connection here too. There is a connection here too. Double connection complete.
So what do I do now? It's done. I simply move the head away from this side.
So I understand that the head is this. The pre pointer of the new item of the head will be pointed to null. New items will be next. The head will move the preface of the head towards the new item and the head will point to the new item. Does anyone have any problems with this?
Everyone understands.
Okay, so our insert first is over.
Now sir, please see if I want to insert the last one. I will insert one at this point. So here again, like before, I have to get a new node. So I took the new node. Let's say the value I want to store in the data for the new node is four.
Then this four will be assigned here.
What do I do now? Here is my last note, if I want to get a point in the last, in my simple English case, if I wanted to insert towards the last, what I would have to do is to run the loop from the beginning and reach the last node, then I could insert into the last, but in this case there is no such problem because there is already a pointer to refer to the last note, which is the last point. So the last pointer that is there is the nex of this last, the nex was not pointed to null. Simply, now I will point to its null, to the new item, in the same way, I will not make this nex, I will make it the last, where it is pointed, is it okay, then my leap is done, now I look at the last, see, first I took a new item.
After taking the new item, let's see if we set the data in the value of the new item in the next step. What will we do if the head is null, that means there is no last in the list. In that case, what will I do? I will put the head in the new item. Just like before, if there was a list MT, what was there? The head will go to the null, the next null of the head will go to the null, and the last will also go to the head. Then there will be a node in the list. If it is not, we will see that there is a list like this. What will we do? It shows that the last of your list has gone to the last again. Which is actually if you point out the last one at the beginning, you wo n't need it anymore.
Because the last one you insert in your fast will already be the last one pointed out. So you won't need it.
This assumes that you do n't know where the last note is. So first, after defining the last note, you are inserting it after the last one. This is not necessary. You can just simply consider that this is towards the last new item, this can be given first, this has to be given later.
Well, first, as I said, I'll write a little code that the next of the last will go to the new item, the pick of the new item will go to the last, the next of the new item will go to the null, and the last will point to the null.
Because you see here why is this not needed? When you are in the middle of this part, when this part is running, dot means first note is being inserted again, then you see in the last line that the head is pointing to the direction you see in the last line, it says last equals to head means the last pointer is going to the head pointer. So, when you have a node that exists, your head is also pointing to this. Last is pointing to this. So, when you insert at the beginning, you keep the last fixed. Suppose you are inserting it towards the first of this. If you are inserting it here, then the last points to this. So, it is already pointing to the last. The point is not out, so there is no need to find it. Have a meeting.
Yes, if I ask you to write the code, then the type is the question type, which is the last class, if I tell you to add a new note in a list like this, I will mention it in the middle or last. If necessary, if you write the required code, then you will have to write some type other than code.
What type are you?
This is a different type of question in the linked list.
How can it be in the linked list? But in the case of the algorithms that you have, the graph is coming or, suppose we will do it in the case of traversing them, in that case you will have to write it again, but in this, it is like giving the code without giving it. You will understand how to give it. There is nothing tricky in it.
Now we will see division. In this case, here is the opposite. Hey, what you want to delete is okay. Suppose you are like before.
If you want to delete a certain value, in that case, you will search from the beginning again.
You know the first and last, but where is a certain data or value? If you know whether it is there or in which mode, whether it is first, last, or middle, then you can find it. So if you find it, the middle one will be deleted, and you can also delete the one at the beginning. If you delete the head, you don't have anything like that, you simply put the head next to the head.
You will have to refer to this note with another note and come back with it. Does it seem like it would be okay to refer here, if so, to point here? What should I do now?
The head came here. So I'll do the head lift or not.
So what? My connection with this has already been broken.
This connection has been deleted. He's making a point here.
So my connection is somewhere else.
That is, if I simply delete this old node here, then my first node will be deleted.
I will call the last one the last one that is already there.
Okay, so the last four points are in. It's on point. After making the points, now I'm going to shift the last node to the last node. It will be the last node. It will point in the direction where the last P is pointing.
So last is now pointing this way. Now I will break the connection. So I'll nullify the text that's in the last one. I will cancel it. And here I will make the fold free. I will make the fold free. If you do this, that room will go.
Okay, now look, if you want to delete any of the middle ones, in this case, you have three things, first, last, and middle, these three things together, so many conditions have been created.
If you say, what do I do with the first old one, next so old one? The old one is pointing towards the head.
And the head is like this, let's say it's pointing to the old one from the beginning like the previous one, and the head shifts to the direction where the old one's next point is.
That means if your two notes in a row are like this, it was a suppository head.
It was a sapoze head. So I call it first old and then I'm shifting this head to the next node first or second and here if you need to do something in between I need something here you find the data first it has to be exactly like this or not like this here I'm not really looking for anyway if you run a y loop if you find a certain data until you get a match with the data of a certain node suppose you want to delete six then you have to find the six first then after finding the six when you see you are in the second node this is then your current node is ok then you shift it okay so you start searching fast the current is going to be in the head the car is going to be pointing to the head you run a y loop until the current value is equal to the data you want to find out which data that data is found out What do you want to do there?
Yes, okay, so what should I do? I will point the car to the direction where the car's next is. Okay, okay, okay, so let's say the car is now pointed at this place. Now my target is to delete the middle, right?
So what should I do first? In the car's prev, where is the car's prev pointed to?
So the car's prev is pointing to this side. The car's prev is actually pointing to the next of the car that it is pointing to.
You said to point to the car's car right.
That means the car's previous next is pointed to the car.
So what should I do with this next pointer except for the car? I will point to the direction where the car's next is pointed to.
So what happened? Now this place is getting run down.
So who did this happen to? With this, yes, it can't be filled before now. It is not double. I just removed the link. Now it's holding it again. Then you do n't have to remove it either. So now I'm going to go to the car next. The pre pointer that is in the car's next was pointing to the car until now, but now that I want to move the car, it is pointing to the direction where the car's print is, so what happened? This place was not pointed to it, but it was pointed to this direction, right? So simply, what should I do now? Will I free this car? The previs of the car? Now when you free the card, all the memory will be empty, then will there be a link? Only the address will be reached, then this link will be automatically moved. The entire space in the memory where the memory was allocated for this note will be completely cleared, okay?
And in a circular link list, simply see that the node next to the last node is in contact with the first node.
This is circular.
It can be double or triple.
This is because it is a sig sarc and instead of just null, it is a connection between the last node and the first node. But see, your head and last nodes all have to be in one place, otherwise you will not understand which node is the head and which is the tail. Then you will understand that it has to be referenced.
Look at the advantage and disadvantage pages. Thank you.
Now tell me, does anyone have any questions for the whole class?
Okay, look at this. We had a note here, how much was in it? There were five. Wasn't that how it was? So I want to delete the node that contains the number five.
So I need to find out where the number five is in my fast.
So what do I do, take a node, sorry, take the new point, that is the current, the current is pointing towards the head, so the car started its journey from here, now I will run the loop until I get this five, then I will keep checking the value of the car, it cannot be that there is a five in the add, maybe, okay, so the value of the car is five, I will run the loop until it is five, and what do I do by continuing this loop, if I don't get it, I will shift to the next one, then the value of the car will be updated every time, then the value of the car will become car. next, so was it at the beginning, then the car did n't come in, now again when, yes, when, again, I matched the value of the car, whether it got a match, it got it, that means the car has come here and stopped, now see, my ultimate task is to delete it, so in the case of deletion, we know that in the linked list, it is connected to the previous one, it is connected to the next one, the next one holds it. It is holding the previous node, it is also holding it, right?
So what should I do? I am holding the previous node, the next node, which is holding this connection, if this node was not there, what would have happened then? This node would have held it, this node would have held it, right?
So what should I do now? I will simply hold the middle node, invisible. What am I doing? The node that the current node points to is not holding the previous one, is it holding the previous one? So I went to the current pointer, so where did I go, here is its point, so where did its next point come from?
This place. I am updating this place.
Until now, this is the car note that was in my next post. But I'm giving up now.
Where will it be? This car's pointer will not stay where you hold it.
So the previous next pointer of the car will now point to the next of the car, where the previous of the car was holding the car, who will go? Now it will hold the car, who will hold it? The next previous of the car will hold the point that is the car that was holding the previous of the car, which was holding the car, so it will simply point to that point. So, my connection has gone, this connection has been made, this connection has been made, this connection has been made, so, between these two, between these two modes, now I have a connection, so what will happen if this node in the middle holds the other two? Now I will just free it, so even if I write it, there is no use, I want to exclude it, and even if it wants to hold us, there is no use, rejected. So I have made it a car, sorry, I have freed the car, I understand that when I free it, the memory that it took up will become empty.
Okay, if anyone has any questions, I have given our course. Okay
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











