WEBVTT

00:00.580 --> 00:05.770
The first operation we are going to learn is our get operation here.

00:05.770 --> 00:13.930
So get operation, which we will develop this get method for our fetching an item to linked list class.

00:13.930 --> 00:15.160
So let's get started.

00:15.160 --> 00:18.610
My name is Typhoon and welcome to another lecture of our course.

00:32.270 --> 00:38.900
So the first operation we are going to learn is get, as I said here, so it will return.

00:38.900 --> 00:41.540
So actually, let's delete all of this.

00:41.570 --> 00:42.590
Delete, delete.

00:42.590 --> 00:44.660
So it will return.

00:46.190 --> 00:46.640
Here.

00:46.640 --> 00:48.110
This is our get.

00:49.850 --> 00:56.270
And this jet operation here will return the node here.

00:56.270 --> 00:59.270
So the node will return the node.

00:59.300 --> 01:07.520
So if this node, if the selected index is out of bounds, then it will return the null here.

01:07.730 --> 01:11.690
So then it will return null.

01:14.300 --> 01:17.760
So let's get started with developing our application now.

01:17.780 --> 01:20.060
Firstly, let's make it a bit.

01:20.890 --> 01:21.490
Here.

01:22.670 --> 01:23.060
Oops.

01:26.300 --> 01:27.050
Here.

01:27.560 --> 01:30.170
So now we're going to develop our application.

01:31.320 --> 01:38.430
So after the our template linked list here under the linked list here, we will develop something.

01:38.430 --> 01:41.300
So we will create first created um, template.

01:41.310 --> 01:50.340
The type name is going to be type name is going to be T again type name T and here we will develop the

01:50.340 --> 01:52.680
node class T here the.

01:53.670 --> 01:55.480
Well, this is going to be linked List.

01:55.500 --> 01:57.180
Linked list.

01:57.960 --> 02:00.120
And here we will develop the get method.

02:00.120 --> 02:02.340
So get index.

02:03.000 --> 02:08.300
So here we will firstly check if the index is out of bounds or not.

02:08.310 --> 02:11.760
In order to do that, we will create a if condition.

02:11.760 --> 02:24.300
So if our index is less than zero, index is less than zero or is index is greater than my count, then

02:24.300 --> 02:26.070
return null.

02:27.090 --> 02:30.060
So as I as we wrote here.

02:30.060 --> 02:32.220
So it will return null here.

02:32.220 --> 02:38.370
So in this case our null statement, the newly returning code is done here.

02:38.970 --> 02:41.430
Also, we created our get here.

02:41.910 --> 02:46.630
So now we just need to return a node if everything is okay.

02:46.650 --> 02:51.000
So here after the if we will start from the heat here.

02:51.000 --> 02:54.960
So Node node here.

02:54.960 --> 02:57.840
So we will make it heat.

02:58.320 --> 03:01.830
So as you can see here, heat is a node type.

03:03.340 --> 03:05.230
Function here, as you can see here.

03:05.410 --> 03:06.370
So.

03:07.320 --> 03:08.760
This is heat.

03:12.390 --> 03:12.940
You get?

03:14.860 --> 03:15.760
After that.

03:17.690 --> 03:19.840
Are we going to iterate with for loop?

03:19.850 --> 03:24.590
So we will iterate through the linked list elements until it finds the selected index here.

03:24.590 --> 03:34.460
So integer E here equals zero while the e is less than index, then increment E by one.

03:34.880 --> 03:40.070
After that we need to hear note and here after that.

03:40.100 --> 03:46.640
Next we will make note here and after the function here.

03:47.630 --> 03:50.480
We will return Node itself here.

03:50.600 --> 03:51.620
Return Node.

03:51.650 --> 03:52.550
So that's it.

03:52.550 --> 04:01.020
As you can see here, we developed all of the implementations here, so let's delete all of them here.

04:01.040 --> 04:07.340
So as you can see here, the complexity of the get operation is o here.

04:08.170 --> 04:11.860
Oh, and actually let me write the text.

04:11.860 --> 04:17.200
So the complexity of this operation is zero and N here.

04:17.500 --> 04:25.540
So since it has to iterate through the n elements here, so the elements is the this is the n elements

04:25.540 --> 04:26.620
in this case.

04:26.650 --> 04:27.700
Oops, not like this.

04:27.700 --> 04:30.550
So this is the n elements.

04:30.550 --> 04:33.610
The N is the number of elements which is here.

04:34.810 --> 04:36.010
N elements.

04:37.780 --> 04:41.520
And this you can find the element count here.

04:42.090 --> 04:43.230
The this is the worst case.

04:43.230 --> 04:47.510
If the element is at the last year at the end of the our node.

04:47.520 --> 04:49.170
So however.

04:50.430 --> 04:59.490
In the best case, the complexity can also be the zero here, zero one here.

05:00.180 --> 05:03.270
So the zero one in the list here.

05:03.270 --> 05:05.430
So no matter which index is selected.

05:05.940 --> 05:07.200
So if our.

05:07.990 --> 05:09.330
Node is the first here.

05:09.340 --> 05:12.370
So for example, one oops, not like this here.

05:12.370 --> 05:14.410
So if our list is like that here.

05:14.410 --> 05:17.970
So this is our first here.

05:17.980 --> 05:20.710
So this is our.

05:22.170 --> 05:24.900
The usual time complexity.

05:24.900 --> 05:27.740
And this is the best case scenario.

05:27.750 --> 05:30.360
In the worst case scenario, it's going to be here.

05:31.230 --> 05:34.200
In worst case scenario, it's going to be the last item.

05:34.200 --> 05:40.410
For example, if our node has three nine items, it will be the nine here.

05:40.410 --> 05:43.680
So this is our worst case scenario for the node here.

05:43.680 --> 05:47.850
However, in every node you will have different number of items.
