Hello, my name is Stephan.
And in this lecture of our course, we will develop a singly linked list in ADT.
So let's get started.
So the single linked list, also known as just the linked list here.
Linked.
Linked list.
Is a sequence of items that is linked with each other.
It's actually a chaining of nodes.
So where each node contains the items value and the next pointer.
So in other words, each item in the linked list has a link to its next item on sequence.
The thing is that differs between the linked list and the node chain is that the linked list has a heat.
Has a head and a tail.
So has a head and tail pointer.
So the heat.
The heat here informs the heat here.
Informs the first item and the tail here.
Informs the last item in the linked list.
So similar to the list ADT, we have learned earlier the linked list has actually let me write it here.
Linked list has get.
We link this has get insert insert.
The search.
And lastly remove operations re.
Move.
So we are all of the operations have the same functionality compared to that we learned previously list
here.
So however, since we now have the heat here.
The heat.
And tell.
Pointers for these head and tail are pointers actually.
So we will also create other operations that these are.
We will create the insert hale in.
Insert.
So we're going to create the insert.
Hit.
Insert.
Hit.
We will also create the insert tail in.
Swordtail.
And we will also create the remove head and remove tail here.
So remove.
Heath.
And remove tail.
Remove tail.
Here.
So now the declaration here.
So we we will declare all of these items in our linked list here.
So we will declare all of these items here in this section of our course.
So actually, let's delete.
Let's delete this.
That we want to use here for now.
Also, delete this.
Delete this.
I'll delete all of them so we won't use them, actually.
In this lecture.
Here.
And we will show you now here.
So this little, this, this and here, I'm not deleting this because I will show and make the checkboxes
around them.
So we will notify that we already created that here.
So now firstly, we will create a linked list class.
So we will also use the template template Typename t typename t here and now.
After that we're going to create the class class linked list.
And here we will private.
We will create my count so we will make private my count here.
So this is going to be an integer.
And will all other operators, we will define it public here, public.
So we will first need to the first node in the list.
It's our new list empty.
So node here t template and pointer it.
So here, as you can see, we got an error here.
That's because no template named node here.
So what we will create it and fix it now while we are writing our code and after that we are going to
create the node here.
T.
Or.
Yeah, we will.
We will use the previously created codes.
That After that we will add this code on it.
So firstly, we will create a tail.
So here and we will also create a constructor, of course.
So Linkedlist constructor here and we will get operation.
So the get operation is going to be not here to.
And get.
Yet.
It's going to be get index integer index.
We will also use the insert.
So now actually, let me open our lectures that we did some projects in previous lectures, the previous
section, and at that section we had some text that we have written in last lecture.
So this is the A to creating and changing note with different data types.
So we will copy this and paste it here.
Here and we will get this linked list after the node class here.
After the node class.
Also delete this template.
So after the node class and print node we will create, we will paste this, our linked list here.
We will also need two template here.
So template type name.
T so template typename t here.
And after that.
So we have a get here.
We get, get, get, get operation here.
So we will also use the insert here.
So void insert hit value value or under case value here.
Civil and void insert.
Hail, insert.
Hail or insert.
Hail to Val.
And also we will just need and as you can see, we have the link, the constructor we have here, we
have get method insert hit we have here.
Insert hit.
Insert tail.
Here.
And let's write our application now.
Insert tail and we will also use the remove here.
So that's why we need to remove.
Remove And for remove we get an a parameter index.
So we will remove according to the index here.
Integer index.
And we will.
So these are the removal operations here.
Uh, remove here.
And insert tail insert hit.
So actually, let's make this comment here.
So these are the insert operations.
Operations.
So insert hit, insert tail.
Just and lastly, just a regular insert here.
So.
Insert and insert here.
It's going to be get index and value.
So integer index and value here.
So after that, this is the index operation operators here and now this is the remove operations operations.
After that, we firstly, we're going to create the void, remove, hit, remove.
He'd also void, void.
Remove tail.
And, uh, that's it with the removal operations.
So we have insert.
Insert tail, insert head and remove tail, remove heat and remove here.
So lastly, we need to declare our.
Um, our search here.
But, uh, before that.
Yeah, let's actually create our search here.
So this is search operation operations.
The searches.
As you can see, this is just a one method.
So integer value, we will get search inside the search.
We're going to get the one parameter that we want to search for here.
And after that, we will use the additional parameters which is here.
The search is also done.
So what we did in the previous lecture, remember hit.
Yes, we did count and print list method in previous lecture here.
So we need to write our count count.
And.
Uh, was also what we need to write is print list.
So print.
List in parentheses we're going to use for method here.
So now.
These are the additional operators.
Operations.
Additional.
At the channel operations or additional operations, which is the.
This is the first count integer count here.
And integer or, uh, this, this actually printing will not return anything.
So we will define it as a void.
Void print list.
Here.
So as you can see in this code, this is the declaration code.
We have the count operation, which has the same functionality as the list in the previous lectures,
which is used to inform us about the number of items in the linked list class.
So there are also the print list operation to make it easier to print the content in the linked list
class.