All language subtitles for 08 - Linked list demo, part 1.en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00.08 --> 00:00:02.00 - [Instructor] So, we're going to go ahead 2 00:00:02.00 --> 00:00:04.02 and create a Linked List. 3 00:00:04.02 --> 00:00:07.01 The type of Linked List we're going to create 4 00:00:07.01 --> 00:00:10.03 is called a Singly Linked List. 5 00:00:10.03 --> 00:00:12.07 Now, there are several versions of Linked List. 6 00:00:12.07 --> 00:00:16.02 Another is W Linked List. 7 00:00:16.02 --> 00:00:18.02 The one that we're doing, a Singly Liked List, 8 00:00:18.02 --> 00:00:22.09 each node in that list stores the contents of the node 9 00:00:22.09 --> 00:00:27.02 and a pointer or reference to the next node in the list. 10 00:00:27.02 --> 00:00:30.05 It does not store any pointer or reference 11 00:00:30.05 --> 00:00:32.00 to the previous node. 12 00:00:32.00 --> 00:00:35.02 That's what a doubly Linked List does. 13 00:00:35.02 --> 00:00:37.09 So, let's go ahead and get started. 14 00:00:37.09 --> 00:00:41.00 If you're following along with the exercise files, 15 00:00:41.00 --> 00:00:45.03 I am on chapter two, Linked List. 16 00:00:45.03 --> 00:00:48.03 And within there, what you definitely want to make sure 17 00:00:48.03 --> 00:00:51.08 that you do, whatever project that you are working on, 18 00:00:51.08 --> 00:00:54.06 you right click on it, and set that 19 00:00:54.06 --> 00:00:57.08 as the default startup project. 20 00:00:57.08 --> 00:01:01.04 Now, I here, am working on the end state. 21 00:01:01.04 --> 00:01:03.04 And when you open this up, you're going to see 22 00:01:03.04 --> 00:01:05.01 my finished product. 23 00:01:05.01 --> 00:01:09.01 But, to follow along, you can go into the begin state. 24 00:01:09.01 --> 00:01:10.09 Which over there, has a blank plate 25 00:01:10.09 --> 00:01:12.02 that you could start working on. 26 00:01:12.02 --> 00:01:15.08 All right, so let's go ahead and jump right into this. 27 00:01:15.08 --> 00:01:18.09 The first thing that we're going to want to do, 28 00:01:18.09 --> 00:01:22.00 is create our node class. 29 00:01:22.00 --> 00:01:26.01 So, I will drop down here on line 17, 30 00:01:26.01 --> 00:01:31.09 and define a class called node. 31 00:01:31.09 --> 00:01:35.04 And within here, we will add our first instance variable, 32 00:01:35.04 --> 00:01:37.07 called data. 33 00:01:37.07 --> 00:01:40.00 And there's a type integer. 34 00:01:40.00 --> 00:01:45.04 Next is our node class itself. 35 00:01:45.04 --> 00:01:47.08 And that's what makes it recursive 36 00:01:47.08 --> 00:01:52.05 because we're define this node that's within node. 37 00:01:52.05 --> 00:01:54.03 And the last thing we'll want to do here, 38 00:01:54.03 --> 00:01:57.09 is to be able to display the content. 39 00:01:57.09 --> 00:02:03.00 And so, I will define a straight forward display, 40 00:02:03.00 --> 00:02:06.04 node, method. 41 00:02:06.04 --> 00:02:11.05 And within here, the content of data. 42 00:02:11.05 --> 00:02:14.07 And, just to make it a little bit easier on the eyes, 43 00:02:14.07 --> 00:02:18.05 we'll put it within brackets. 44 00:02:18.05 --> 00:02:23.02 And actually that's the greater and left hand symbols. 45 00:02:23.02 --> 00:02:25.08 Now, technically brackets, for those of you 46 00:02:25.08 --> 00:02:28.07 that are pointing out that flaw. 47 00:02:28.07 --> 00:02:30.06 And there we go. 48 00:02:30.06 --> 00:02:34.07 This will create our node class that can print out data. 49 00:02:34.07 --> 00:02:38.06 Next, let's go ahead and create the Singly Linked List class 50 00:02:38.06 --> 00:02:41.03 that will actually use this node. 51 00:02:41.03 --> 00:02:44.06 I'll start off, just public class 52 00:02:44.06 --> 00:02:49.02 and call it Singly Linked List. 53 00:02:49.02 --> 00:02:53.05 And within here, we will have a private node 54 00:02:53.05 --> 00:02:56.02 that I will call first. 55 00:02:56.02 --> 00:02:58.05 Now the next thing that I want to do here, 56 00:02:58.05 --> 00:03:03.05 is to add in a method that is called is empty. 57 00:03:03.05 --> 00:03:04.08 That, as the name applies, 58 00:03:04.08 --> 00:03:07.06 is to check to see if the node is empty. 59 00:03:07.06 --> 00:03:08.08 Now what we want to check to see, 60 00:03:08.08 --> 00:03:12.00 is if the first node points to null, 61 00:03:12.00 --> 00:03:15.04 then we know that we have no nodes. 62 00:03:15.04 --> 00:03:18.09 And that's what this value is going to return. 63 00:03:18.09 --> 00:03:23.08 So, let's go ahead and enter in public, 64 00:03:23.08 --> 00:03:26.03 and it's going to return a boolean type. 65 00:03:26.03 --> 00:03:29.02 Check is empty. 66 00:03:29.02 --> 00:03:37.01 And we will return the value of the first being null. 67 00:03:37.01 --> 00:03:41.00 And that again is because if the first points to null, 68 00:03:41.00 --> 00:03:44.02 we have no nodes that it needs to be known. 69 00:03:44.02 --> 00:03:46.01 The next method we're going to write, 70 00:03:46.01 --> 00:03:49.00 is to insert the first node. 71 00:03:49.00 --> 00:03:50.03 It's going to be used to insert 72 00:03:50.03 --> 00:03:53.01 at the beginning of the list. 73 00:03:53.01 --> 00:03:57.08 So, we're going to call this insert first. 74 00:03:57.08 --> 00:04:01.09 And, as a parameter, it will take in the integer type 75 00:04:01.09 --> 00:04:04.03 of data. 76 00:04:04.03 --> 00:04:10.09 And within here, our first step is to define a new node. 77 00:04:10.09 --> 00:04:13.01 Create that instance. 78 00:04:13.01 --> 00:04:17.03 And in the new node, we will assign it's data, 79 00:04:17.03 --> 00:04:22.07 the value of data that was just passed in. 80 00:04:22.07 --> 00:04:26.09 On the next line, we're going to assign it's property 81 00:04:26.09 --> 00:04:31.02 of next to first. 82 00:04:31.02 --> 00:04:39.05 And then lastly, we will have first equal two new node. 83 00:04:39.05 --> 00:04:41.06 So, again what's happening is, we are assigning 84 00:04:41.06 --> 00:04:45.08 this new node data passed in to this method. 85 00:04:45.08 --> 00:04:49.08 And the new nodes next field should point to the first. 86 00:04:49.08 --> 00:04:52.07 Now, let's set up a method to do the opposite. 87 00:04:52.07 --> 00:04:56.04 Which is to remove a node. 88 00:04:56.04 --> 00:05:00.01 We will call it delete first. 89 00:05:00.01 --> 00:05:04.01 So it's removing a node, but specifically the first node. 90 00:05:04.01 --> 00:05:04.09 And this is the great thing 91 00:05:04.09 --> 00:05:07.07 about when you become comfortable with writing algorithm. 92 00:05:07.07 --> 00:05:11.03 You can make it as powerful and as detailed as you want. 93 00:05:11.03 --> 00:05:13.01 There's no limit to all the different functionalities 94 00:05:13.01 --> 00:05:15.09 that you can add to it. 95 00:05:15.09 --> 00:05:21.02 And this delete first method, I'll first define node 96 00:05:21.02 --> 00:05:24.02 with the variable name as temp. 97 00:05:24.02 --> 00:05:28.00 And I will assign it first. 98 00:05:28.00 --> 00:05:30.07 And toward the bottom here, I'll go ahead 99 00:05:30.07 --> 00:05:34.07 and just return temp to get rid of that. 100 00:05:34.07 --> 00:05:36.00 Compiler. 101 00:05:36.00 --> 00:05:36.09 I like doing that. 102 00:05:36.09 --> 00:05:38.09 Just not having any squiggly lines 103 00:05:38.09 --> 00:05:43.09 while I'm coding and disturbing my flow and concentration, 104 00:05:43.09 --> 00:05:46.02 even though I only have one more line to write. 105 00:05:46.02 --> 00:05:48.06 Which is the second line. 106 00:05:48.06 --> 00:05:56.04 And that is to assign first to the next value of first. 107 00:05:56.04 --> 00:05:58.05 The next method we are going to create is to display 108 00:05:58.05 --> 00:06:00.03 the list and then also another one 109 00:06:00.03 --> 00:06:02.09 for inserting a last node. 110 00:06:02.09 --> 00:06:04.05 Those are up next. 8350

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.