Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
1
00:00:05,220 --> 00:00:07,350
Alright, so for challenge number two,
2
2
00:00:07,350 --> 00:00:10,090
I want you to work with a singly-linked list
3
3
00:00:10,090 --> 00:00:13,930
that handles integers, so it stores integer objects.
4
4
00:00:13,930 --> 00:00:16,450
So what I've done is, I quickly updated
5
5
00:00:16,450 --> 00:00:20,020
the employee link list class that we implemented
6
6
00:00:20,020 --> 00:00:23,690
so that it stores integers instead of employees.
7
7
00:00:23,690 --> 00:00:25,760
I was gonna make you do it, but then I thought,
8
8
00:00:25,760 --> 00:00:28,720
oh that's just trivial work, so I'll do that for you.
9
9
00:00:28,720 --> 00:00:31,300
So there's a starter project in the resources section
10
10
00:00:31,300 --> 00:00:33,480
that contains all the code that you'll need,
11
11
00:00:33,480 --> 00:00:35,070
and what I want you to do is, I want you
12
12
00:00:35,070 --> 00:00:38,220
to implement a method in the IntergerLinkedList class
13
13
00:00:38,220 --> 00:00:40,570
that inserts a value in sorted order.
14
14
00:00:40,570 --> 00:00:41,930
If you look at the class, I think
15
15
00:00:41,930 --> 00:00:44,340
I called the method insertSorted,
16
16
00:00:44,340 --> 00:00:47,910
and instead of calling the add to front method,
17
17
00:00:47,910 --> 00:00:49,960
we'll keep calling insertSorted
18
18
00:00:49,960 --> 00:00:53,150
and so the values are always inserted in sorted order.
19
19
00:00:53,150 --> 00:00:55,040
And what I mean by sorted order is
20
20
00:00:55,040 --> 00:00:57,850
that the lower values should appear first in the list,
21
21
00:00:57,850 --> 00:00:59,760
so they should be closer to the head.
22
22
00:00:59,760 --> 00:01:02,990
And so if we were to insert value four,
23
23
00:01:02,990 --> 00:01:06,110
and then two, and then one, and then five,
24
24
00:01:06,110 --> 00:01:07,620
the list would look like the following.
25
25
00:01:07,620 --> 00:01:10,200
You'd have the node for one, and then the node for two,
26
26
00:01:10,200 --> 00:01:11,930
and then four, and then five,
27
27
00:01:11,930 --> 00:01:14,260
and five would be the last node in the list,
28
28
00:01:14,260 --> 00:01:16,250
and its next field would point to null.
29
29
00:01:16,250 --> 00:01:18,820
And so IntegerLinkedList is a singly-linked list,
30
30
00:01:18,820 --> 00:01:21,490
and I want it to remain a singly-linked list,
31
31
00:01:21,490 --> 00:01:23,070
this would be an easier challenge
32
32
00:01:23,070 --> 00:01:24,620
if it was a doubly-linked list.
33
33
00:01:24,620 --> 00:01:28,300
So, as I said, the project contains all the code you'll need
34
34
00:01:28,300 --> 00:01:31,150
and the main method has the code that should work
35
35
00:01:31,150 --> 00:01:33,860
when you're finished, so when you've finished implementing
36
36
00:01:33,860 --> 00:01:37,470
the insertSorted method, you can then run the main method,
37
37
00:01:37,470 --> 00:01:40,410
and the list that prints should have the nodes
38
38
00:01:40,410 --> 00:01:41,520
in sorted order.
39
39
00:01:41,520 --> 00:01:42,820
So, good luck with that,
40
40
00:01:42,820 --> 00:01:44,803
and I'll see you in the solution video.
3586
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.