Hello all and welcome back.
So in this video let us continue and now learn about different operations which we can perform on our
linked list.
So let's get started.
Now talking about different operations which we can perform on our linked list.
First we have a linked list in front of us, right.
So we have this whole linked list of five nodes which is in front of us.
The last node will of course be pointing to none.
So let me write it like this.
Yeah.
Great.
So when we think of operation, the very first I believe is something which is inserting a node, right.
So when we were even creating our linked list from scratch, we were able to insert our nodes into that
list.
So now if I have been given a particular linked list, then I believe we should be able to add nodes
to it.
So different things which we can now do in insert is inserted head right.
Then let me just write it in this way.
So second.
Yeah.
So first is insert at head.
Insert at tail.
And we should be able to insert somewhere in between as well.
Right.
Insert in between.
Let's say using an index.
So I believe all of them are pretty explanatory.
So inserting at head is of course possible in linked list.
When we will be writing the code for that, we will be comparing them with array, counter array or
list counter part as well.
But inserting at head is just I'm just changing my head, right?
Then inserting a tail at the last and we can of course insert in between as well, right?
So the second option I believe, which we can do is we can insert.
Then we can of course delete as well.
Right.
So for delete we can either again delete our head.
Second.
Yeah.
Delete head.
Delete till.
We can also delete in between.
Right.
We can delete by index.
So if you give me an index let's say in the linked list which we are seeing in front of us.
If you say that hey delete this first node.
So I'm taking zero indexing.
So this is going to be zero.
Let me write that down zero one.
0123 and four.
Right.
So this is index.
So when you say that hey delete the second uh index node.
Then I will delete 30.
And I will just somehow join this okay.
Great.
And the last one is going to be delete by value.
So something which I also want to support deleting the same thing by value.
So tomorrow you can ask that hey delete the node which is having value 40.
So I will just delete the third node in this particular linked list.
Right.
Okay.
So let's move forward and see other options.
Next one.
If we can do the same thing then I think we can also do search.
So just like in an array you were able to search right in an array or list you were able to search.
We should be able to tell.
So search by index.
And what exactly is kept at this particular position.
Okay.
And the next one can be search by value.
If this particular value is present or not.
Okay.
So yeah this is the case.
And one more operation which I think we should do is traverse.
So this is actually something which you have already done.
So in traverse let me just take some space and write it in traverse.
What's going to happen.
We are just going to print our list right.
So we have already seen that we have written the code to print out linked list both iteratively as well
as record using recursion.
Right.
Great.
So yeah, these are all the basic operations which I believe we can perform on our linked list.
Now in the next videos which will follow, we are going to make sure that we are able to do each and
every of these operations and understand the complexity behind this, then see how they are in comparison
to our array.
So that towards the end, when we have done all these operations, we have a good idea that exactly
how our linked list in comparison to my eraser list and many questions which you will be doing right.
In future it will be just combination of these things only right.
The way you are traversing your array, the way you are able to, let's say search or delete or insert,
right?
So if we master all these operations, then we will be at a very good place to do any questions.
And that is the beauty of linked list.
Like if you are able to do these basic operations, you will see that 80 to 90% you will be done with
that.
Okay.
So great.
Then everyone let's meet in the next videos and let us do these operations one by one.
Thank you.