Check out a free preview of the full The Last Algorithms Course You'll Need course

The "Linked List Q&A" Lesson is part of the full, The Last Algorithms Course You'll Need course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen answers student questions regarding using VIM, if setting remove undefined would break, where the methods are taken from, and the reason for using the Java methods.

Preview
Close

Transcript from the "Linked List Q&A" Lesson

[00:00:00]
>> Are you using when here?
>> Using vim.
>> Yeah, vim
>> I always use Vim, okay? It's literally my entire online shtick is the fact that I use Vim. And I might be like the second fastest, there's word that George Hotz is faster than me. I don't know.

[00:00:21]
But one day we'll have a competition. Maybe he'll join me and do a 25 algorithm super speed run.
>> I might have another bug.
>> Gosh, please do.
>> If you do remove undefined. And current is undefined. Well, everything will just blow up
>> No so let's look at that.

[00:00:41]
That's good question. So the question was, if we did remove undefined and current undefined would we blow up? Well one, you'd have to be breaking the contract which you did. The duty is ignore which we all know when you do that you have to go work at Facebook for a year.

[00:00:53]
So nobody wants to go do that, right? It's a joke, enjoy the joke. So there's plenty of people that wanna work my best friends, [SOUND] [LAUGH] My views are my own, okay, anyway. [LAUGH]
>> Second, this right here is the value that we're comparing. It's the container node that we're comparing.

[00:01:11]
So it's not
>> So I could break it, [INAUDIBLE]
>> No ,no it's the container node even if you did break the contract, what would end up happening is that, remember, it's the containing node or it's the container's value that we're comparing, right? So currents.value would have to then equal undefined.

[00:01:33]
Which means that current does exist, which means that it could be removed.
>> Sure-
>> [CROSSTALK]
>> [INAUDIBLE]
>> Yes, you'd actually have to instantiate this thing. Can you even do that? Can you do const test equals doubly linked list, undefined? Is that possible? Besides for the fact that I'm not You can't do that.

[00:02:05]
Really, did I just, my goodness, what am I doing? There we go. Yeah, okay, that makes sense. Well does make any sense I don't know why you do that but yes you can do that. That doesn't break anything, right? Because it's the value that we're comparing at right?

[00:02:21]
So since we're not comparing the node, we're comparing the value within the container. So that means it has to be a value provided which means my node does exist, which means I should be able to remove it.
>> And the methods you have written are mainly for JavaScript.

[00:02:40]
>> I think what I did is I honestly went to Java list and took Oracle helps my goodness, [SOUND] I took a lot of these not contains all get there is removed. So you have a remove index, we can't overload functions. So I'd like rename them remove became remove at, remove object, right there became this whole thing.

[00:03:08]
>> Is there any specific reason you have chosen Java or JavaScript when doing this coding for the building list?
>> So the reason why I chose JavaScript over Java, that's the question and so the-
>> Java or JavaScript I think you have shown the Java methods right?
>> Yeah I showed the Java methods because Java is a fairly complete language and it's a pretty easy language to show a lot of computer science kind of topics and right?

[00:03:35]
It's easy it's safer you're not gonna [INAUDIBLE] Yourself. You bet you will get no pointer exceptions right? You will get these other things, it's a fairly simple language to kind of make these comparisons in. So I just kind of brought it over I used TypeScript because it's the most accessible language right now.

[00:03:49]
C is obviously the best because it really just shows you that raw memory is raw memory and you tell it what it is and that's what it is, right?. And so I didn't do it that way.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now