WEBVTT

00:00.550 --> 00:01.690
Hello, my name is Stephan.

00:01.690 --> 00:07.180
And in this lecture of our course, we will develop a singly linked list in ADT.

00:07.330 --> 00:08.740
So let's get started.

00:21.330 --> 00:27.320
So the single linked list, also known as just the linked list here.

00:27.360 --> 00:28.440
Linked.

00:31.630 --> 00:32.950
Linked list.

00:35.480 --> 00:39.470
Is a sequence of items that is linked with each other.

00:39.470 --> 00:41.000
It's actually a chaining of nodes.

00:41.000 --> 00:45.950
So where each node contains the items value and the next pointer.

00:45.950 --> 00:55.310
So in other words, each item in the linked list has a link to its next item on sequence.

00:55.520 --> 01:04.400
The thing is that differs between the linked list and the node chain is that the linked list has a heat.

01:08.080 --> 01:10.900
Has a head and a tail.

01:11.170 --> 01:15.160
So has a head and tail pointer.

01:15.160 --> 01:16.960
So the heat.

01:16.990 --> 01:21.700
The heat here informs the heat here.

01:22.740 --> 01:27.540
Informs the first item and the tail here.

01:28.520 --> 01:32.350
Informs the last item in the linked list.

01:32.360 --> 01:40.280
So similar to the list ADT, we have learned earlier the linked list has actually let me write it here.

01:40.610 --> 01:42.980
Linked list has get.

01:45.130 --> 01:49.780
We link this has get insert insert.

01:51.840 --> 01:52.650
The search.

01:59.420 --> 02:03.970
And lastly remove operations re.

02:04.720 --> 02:05.350
Move.

02:08.260 --> 02:16.990
So we are all of the operations have the same functionality compared to that we learned previously list

02:16.990 --> 02:17.680
here.

02:18.550 --> 02:22.510
So however, since we now have the heat here.

02:22.630 --> 02:24.010
The heat.

02:24.740 --> 02:26.480
And tell.

02:27.910 --> 02:30.490
Pointers for these head and tail are pointers actually.

02:30.490 --> 02:34.490
So we will also create other operations that these are.

02:34.510 --> 02:38.350
We will create the insert hale in.

02:40.380 --> 02:41.970
Insert.

02:42.510 --> 02:44.610
So we're going to create the insert.

02:44.640 --> 02:45.510
Hit.

02:45.510 --> 02:46.800
Insert.

02:46.830 --> 02:47.730
Hit.

02:49.670 --> 02:54.500
We will also create the insert tail in.

02:55.360 --> 02:56.650
Swordtail.

02:58.740 --> 03:02.430
And we will also create the remove head and remove tail here.

03:02.430 --> 03:03.960
So remove.

03:06.060 --> 03:06.720
Heath.

03:12.940 --> 03:14.800
And remove tail.

03:19.240 --> 03:20.110
Remove tail.

03:23.580 --> 03:24.120
Here.

03:24.240 --> 03:26.780
So now the declaration here.

03:26.790 --> 03:34.050
So we we will declare all of these items in our linked list here.

03:34.050 --> 03:40.410
So we will declare all of these items here in this section of our course.

03:40.410 --> 03:42.510
So actually, let's delete.

03:43.420 --> 03:44.920
Let's delete this.

03:46.270 --> 03:49.120
That we want to use here for now.

03:49.510 --> 03:50.980
Also, delete this.

03:51.730 --> 03:52.960
Delete this.

03:55.000 --> 03:57.790
I'll delete all of them so we won't use them, actually.

03:59.030 --> 04:00.080
In this lecture.

04:05.300 --> 04:05.930
Here.

04:13.570 --> 04:15.520
And we will show you now here.

04:15.520 --> 04:24.280
So this little, this, this and here, I'm not deleting this because I will show and make the checkboxes

04:24.280 --> 04:24.760
around them.

04:24.760 --> 04:29.590
So we will notify that we already created that here.

04:29.590 --> 04:34.780
So now firstly, we will create a linked list class.

04:34.780 --> 04:43.810
So we will also use the template template Typename t typename t here and now.

04:43.810 --> 04:50.920
After that we're going to create the class class linked list.

04:50.920 --> 04:53.260
And here we will private.

04:53.260 --> 04:57.910
We will create my count so we will make private my count here.

04:57.910 --> 04:59.350
So this is going to be an integer.

05:00.680 --> 05:06.470
And will all other operators, we will define it public here, public.

05:06.470 --> 05:09.770
So we will first need to the first node in the list.

05:10.280 --> 05:12.260
It's our new list empty.

05:12.260 --> 05:19.130
So node here t template and pointer it.

05:19.880 --> 05:22.190
So here, as you can see, we got an error here.

05:22.190 --> 05:24.800
That's because no template named node here.

05:24.800 --> 05:33.680
So what we will create it and fix it now while we are writing our code and after that we are going to

05:33.680 --> 05:35.360
create the node here.

05:35.360 --> 05:35.770
T.

05:38.040 --> 05:38.640
Or.

05:41.170 --> 05:42.130
Yeah, we will.

05:42.130 --> 05:44.680
We will use the previously created codes.

05:45.730 --> 05:49.390
That After that we will add this code on it.

05:49.390 --> 05:51.340
So firstly, we will create a tail.

05:52.200 --> 05:56.340
So here and we will also create a constructor, of course.

05:56.340 --> 06:02.040
So Linkedlist constructor here and we will get operation.

06:02.040 --> 06:05.430
So the get operation is going to be not here to.

06:07.360 --> 06:08.740
And get.

06:09.840 --> 06:10.050
Yet.

06:10.050 --> 06:12.840
It's going to be get index integer index.

06:13.380 --> 06:15.540
We will also use the insert.

06:15.540 --> 06:25.110
So now actually, let me open our lectures that we did some projects in previous lectures, the previous

06:25.110 --> 06:33.210
section, and at that section we had some text that we have written in last lecture.

06:33.360 --> 06:37.200
So this is the A to creating and changing note with different data types.

06:37.200 --> 06:41.250
So we will copy this and paste it here.

06:43.710 --> 06:49.740
Here and we will get this linked list after the node class here.

06:49.740 --> 06:51.270
After the node class.

06:52.780 --> 06:53.860
Also delete this template.

06:53.860 --> 07:01.120
So after the node class and print node we will create, we will paste this, our linked list here.

07:01.150 --> 07:02.770
We will also need two template here.

07:02.770 --> 07:05.290
So template type name.

07:07.150 --> 07:13.450
T so template typename t here.

07:13.630 --> 07:15.130
And after that.

07:18.640 --> 07:21.550
So we have a get here.

07:21.550 --> 07:24.190
We get, get, get, get operation here.

07:24.190 --> 07:26.140
So we will also use the insert here.

07:26.140 --> 07:35.560
So void insert hit value value or under case value here.

07:38.220 --> 07:40.680
Civil and void insert.

07:40.710 --> 07:42.720
Hail, insert.

07:43.500 --> 07:46.620
Hail or insert.

07:47.850 --> 07:50.400
Hail to Val.

07:51.450 --> 08:00.300
And also we will just need and as you can see, we have the link, the constructor we have here, we

08:00.300 --> 08:05.250
have get method insert hit we have here.

08:06.450 --> 08:07.560
Insert hit.

08:07.560 --> 08:09.000
Insert tail.

08:11.850 --> 08:12.420
Here.

08:12.420 --> 08:14.460
And let's write our application now.

08:15.240 --> 08:18.000
Insert tail and we will also use the remove here.

08:18.000 --> 08:20.100
So that's why we need to remove.

08:20.100 --> 08:23.820
Remove And for remove we get an a parameter index.

08:23.820 --> 08:26.400
So we will remove according to the index here.

08:26.430 --> 08:28.020
Integer index.

08:29.110 --> 08:30.250
And we will.

08:30.280 --> 08:32.680
So these are the removal operations here.

08:32.930 --> 08:34.150
Uh, remove here.

08:37.160 --> 08:39.920
And insert tail insert hit.

08:40.100 --> 08:42.410
So actually, let's make this comment here.

08:42.410 --> 08:45.350
So these are the insert operations.

08:45.380 --> 08:46.690
Operations.

08:46.700 --> 08:49.220
So insert hit, insert tail.

08:49.700 --> 08:52.520
Just and lastly, just a regular insert here.

08:52.520 --> 08:53.180
So.

08:53.270 --> 08:57.290
Insert and insert here.

08:57.320 --> 08:59.750
It's going to be get index and value.

09:00.170 --> 09:04.810
So integer index and value here.

09:04.820 --> 09:12.500
So after that, this is the index operation operators here and now this is the remove operations operations.

09:12.860 --> 09:18.860
After that, we firstly, we're going to create the void, remove, hit, remove.

09:19.680 --> 09:23.970
He'd also void, void.

09:24.060 --> 09:25.710
Remove tail.

09:28.050 --> 09:30.450
And, uh, that's it with the removal operations.

09:30.450 --> 09:32.820
So we have insert.

09:34.690 --> 09:41.410
Insert tail, insert head and remove tail, remove heat and remove here.

09:41.410 --> 09:44.680
So lastly, we need to declare our.

09:45.730 --> 09:48.460
Um, our search here.

09:49.090 --> 09:51.640
But, uh, before that.

09:52.660 --> 09:56.000
Yeah, let's actually create our search here.

09:56.020 --> 10:00.550
So this is search operation operations.

10:00.550 --> 10:01.090
The searches.

10:01.090 --> 10:03.030
As you can see, this is just a one method.

10:03.040 --> 10:08.050
So integer value, we will get search inside the search.

10:08.050 --> 10:12.010
We're going to get the one parameter that we want to search for here.

10:12.310 --> 10:17.290
And after that, we will use the additional parameters which is here.

10:17.290 --> 10:19.030
The search is also done.

10:19.030 --> 10:22.120
So what we did in the previous lecture, remember hit.

10:22.510 --> 10:27.880
Yes, we did count and print list method in previous lecture here.

10:27.880 --> 10:33.100
So we need to write our count count.

10:34.330 --> 10:35.290
And.

10:36.220 --> 10:40.330
Uh, was also what we need to write is print list.

10:40.330 --> 10:41.530
So print.

10:44.610 --> 10:47.940
List in parentheses we're going to use for method here.

10:48.090 --> 10:49.440
So now.

10:51.760 --> 10:53.560
These are the additional operators.

10:53.590 --> 10:54.610
Operations.

10:54.900 --> 10:55.900
Additional.

10:57.610 --> 11:03.770
At the channel operations or additional operations, which is the.

11:04.070 --> 11:07.100
This is the first count integer count here.

11:08.660 --> 11:13.940
And integer or, uh, this, this actually printing will not return anything.

11:13.940 --> 11:16.460
So we will define it as a void.

11:17.630 --> 11:19.910
Void print list.

11:21.790 --> 11:22.330
Here.

11:23.580 --> 11:26.460
So as you can see in this code, this is the declaration code.

11:26.670 --> 11:33.660
We have the count operation, which has the same functionality as the list in the previous lectures,

11:33.660 --> 11:38.740
which is used to inform us about the number of items in the linked list class.

11:38.760 --> 11:48.540
So there are also the print list operation to make it easier to print the content in the linked list

11:48.540 --> 11:49.410
class.
