The first operation we are going to learn is our get operation here.
So get operation, which we will develop this get method for our fetching an item to linked list class.
So let's get started.
My name is Typhoon and welcome to another lecture of our course.
So the first operation we are going to learn is get, as I said here, so it will return.
So actually, let's delete all of this.
Delete, delete.
So it will return.
Here.
This is our get.
And this jet operation here will return the node here.
So the node will return the node.
So if this node, if the selected index is out of bounds, then it will return the null here.
So then it will return null.
So let's get started with developing our application now.
Firstly, let's make it a bit.
Here.
Oops.
Here.
So now we're going to develop our application.
So after the our template linked list here under the linked list here, we will develop something.
So we will create first created um, template.
The type name is going to be type name is going to be T again type name T and here we will develop the
node class T here the.
Well, this is going to be linked List.
Linked list.
And here we will develop the get method.
So get index.
So here we will firstly check if the index is out of bounds or not.
In order to do that, we will create a if condition.
So if our index is less than zero, index is less than zero or is index is greater than my count, then
return null.
So as I as we wrote here.
So it will return null here.
So in this case our null statement, the newly returning code is done here.
Also, we created our get here.
So now we just need to return a node if everything is okay.
So here after the if we will start from the heat here.
So Node node here.
So we will make it heat.
So as you can see here, heat is a node type.
Function here, as you can see here.
So.
This is heat.
You get?
After that.
Are we going to iterate with for loop?
So we will iterate through the linked list elements until it finds the selected index here.
So integer E here equals zero while the e is less than index, then increment E by one.
After that we need to hear note and here after that.
Next we will make note here and after the function here.
We will return Node itself here.
Return Node.
So that's it.
As you can see here, we developed all of the implementations here, so let's delete all of them here.
So as you can see here, the complexity of the get operation is o here.
Oh, and actually let me write the text.
So the complexity of this operation is zero and N here.
So since it has to iterate through the n elements here, so the elements is the this is the n elements
in this case.
Oops, not like this.
So this is the n elements.
The N is the number of elements which is here.
N elements.
And this you can find the element count here.
The this is the worst case.
If the element is at the last year at the end of the our node.
So however.
In the best case, the complexity can also be the zero here, zero one here.
So the zero one in the list here.
So no matter which index is selected.
So if our.
Node is the first here.
So for example, one oops, not like this here.
So if our list is like that here.
So this is our first here.
So this is our.
The usual time complexity.
And this is the best case scenario.
In the worst case scenario, it's going to be here.
In worst case scenario, it's going to be the last item.
For example, if our node has three nine items, it will be the nine here.
So this is our worst case scenario for the node here.
However, in every node you will have different number of items.