@@neillunavat depending on how much exposure you've had, but hey take the time to feel good about yourself LOL post your github, lets see your projects bud
I'm graduating in May 2021 and preparing for Leetcode and Hackerrank technical interview questions. Jacob, your explanation of how Linked Lists work, and the accompanying C implementation is extremely helpful. I mostly program in garbage collected languages like Python and Java, but after watching re-watching your videos and struggling with my compiler for a while, I feel like I finally understand how Linked Lists are implemented under the hood.
I gotta be honest all of this is great and all but if you're gonna use linked list a lot then implementing them each time will be such an exhausting and time wasting process so it's better that after you understood how they work that you create functions ready for use when ever you want so that you don't implement time every single time.
Perfect demonstration that learning to program only in very high level languages such as Java, Python etc will always hide from you the elegant simplicity and beauty of data structures ...
Amazing video. I am taking an online programing course and for homework, i got stuck with trying to implement a linked-list in C. I understood the theory, but this video helped me see how to actually use it in code. Amazing video. Very smart guy. I had to pause the video and write the code in pen for the first 10 mins until I saw what was happening. Thank you very much.
One cool trick with linked list and arrays is instead of having a really long array, or a really long list, you have a linked list of pointers to multiple arrays. That way you can easily sort values into arrays without a single one getting too large.
Nobody spoke up. So, I kept going. :) Seriously, I do slow down in person, when I can gauge from student faces how things are sinking in. Fortunately, with RUclips you can replay and watch it at reduced speed.
@@JacobSorber haha true that. I do have difficulty understand some other pieces of the code though that weren't explained what it does. But overall I think better to understand than my professor.
This Professor is brilliant. I love using your videos Jacob! They really lit up those areas of my brain that needed to grasp C. From a dull glow to a flashing glare! Thanks so much.
THE FIRST 30 seconds!! you called me out majorly lol. I was speaking with my prof about some confusion on an assignment (I'm a senior) and he said "well linked lists are something you know already from your intro classes so that part should be easy" I immediately clammed up out of embarrassment and now here I am. Thank you for making this video.
Hello sir I'm from India.....I get this video by connecting vnp. So that, no video from my location shall not be in the search list......and I found you.....a great teacher.....thank you.....I'm subscribing you
Thank you so much I really appreciate the effort and patience you put into your videos , I have my exam tomorrow and I was struggling to understand the concept and it's implementation throughout the semester but your explanation came in handy and made things easier for me ; wish me luck 🤞
Dude THANK YOU. You just made me understand pointers to pointers in a single line with that insert_at_head. I always thought it only served to pass arrays of pointers and chars
Thank you very much for the wonderful explanation. I would to add a function to free memory after we have used it. void free_list(node_t *head) { node_t *tmp = NULL; while (head !=NULL) { tmp = head; // Store the current head to tmp head = head->next; // Move to the next node free(tmp); // Free the current node } }
Thank you. I really like that you understand what you're talking about and it feels like you really enjoy programming, which makes it fun and easy to follow you.
Thank you for the video. I do have to say the portions where you actually write code are simply too fast for me. I am aware I can pause but I might have to pause every 2 seconds at some parts which gets tedious quickly.
You're the best man ... Can you please make a video on struct node** head_ref and struct node* head_ref ? I'm just confused with double pointers in linkedlist.
Thank you so much for making this awesome video, I got confused after going through a three-hour lecture. But this video just helps me solve that confusion within 30 minutes.
I'll say something & probably will get lambasted, I've been through 10 to 20 tutorials on DSA. I search DSA through C/C++ on RUclips and hundreds of subpar, half-arsed tutorials of incompetent people ( who possibly don't even know what they're doing ) pops up and it's so annoying because not only you've a problem that require DSA comprehension but now you also have another issue of finding a decent resource. I'm glad I found this channel amid heaps and piles of trash. Thank You!
HOLY CRAP I LOVE THIS VIDEO THANK YOU. The general concept just did not click in my head bit watching this video made me realise how it works it all makes sense now. Definitely subscribing just for that.
I'm not sure if this is that best way to handle this, however in the video there was no code on adding a node to the end of the list so I came up with this. Where you pass in the head of the list and the create_new_node function. ex. insert_at_end(head, create_new_node(55)); void insert_at_end(node_t *head, node_t *newnode){ node_t *tmp = head; while(tmp->next){ tmp = tmp->next; } tmp->next = newnode; }
@@JacobSorber I ask if you ever considered using rust instead of c and c++? In a comment on another of your videos. Just interested because i come From a language theory perspectiv so it is fun to hear the what you thought about it.
Thank you so much !! I didn't know how to manipulate my *head pointer well to find a node in my list for inst. This was so confusing but now i know better thanks to you :D
I really like the way you explain. Being a C developer and given the fact that linked-lists were uncharted areas for me, i found this really helpful. In fact i fixed a bug in a piece of code at work that i had implemented. :) It would be really interesting to see free memory malloced for the nodes, once you're finished with linkedLists work.
Thanks. I'm glad it was helpful. I don't completely understand your request, though. Are you wanting to see how memory allocators work? Or are you looking for some variant on what I did here with my linked list?
@@JacobSorber actually a variant. You could show how the allocated memory can be freed, once the work with linkedlist has been completed. I would also typecast those mallocs like (node_t*)malloc since they return void* by default. :-)
thank you very much , your videos are so simple to understand yet so enriched with information and well explained details i tried to save a linked list and to save in a binary file then reading it but i struggled a lot if make a video about this topic that would be great !!
In my career as a HPC programmer, I only used a linked list once. That was 8 years ago, before I found out that a simple array is 1000x faster. And then I found out that you can get another 100x speedup on GPU with OpenCL. As much as I like programming concepts, data structures like linked lists are inefficient nonsense. And sadly most computer science students never learn optimization, so their software runs slow like molasses.
A different approach would be to create a Node constructor and pass in the data there. So you could write something like // Node could be static? static class Node { Node next; int data; public Node(int data) { this.data = data; } } // Part of the Linked List class public void add(int data) { Node newHead = new Node(data); newHead.next = head; head = newHead; } Each their own approach I suppose, this is just another option for anyone who's interested. Learned this approach from a HackerRank video for anyone interested.
Thanks. Yes, having a constructor on the node, and pulling it out of the Linked List class is definitely an option. It really depends on the abstraction you want.
one of the best videos about linked lists. enjoyed it although i'm not new to this topic. would've liked a little bit big-o-notation though. and - some addition to the still outstanding content - i think calling them 'chains' instead of lists would be more intuitive.
Hi, thank you so much for your video, I'm just a beginner to programming and C.I was following you step by step and understanding every line you wrote, but when it came to the part of the for loop, I don't understand why the head value has to be initialized in 'NULL' for the printlist function to work, I just realized that if I don't assign that value to the head pointer I get an error "segmentation fault core dumped". If the list is created, I printed out the head value and I obtain 24, why the function does not work. I tried to read about the error but I still don't understand it. Thank you so much again.
I'm not 100% sure I completely understand the question, but we're using NULL to mean that a pointer doesn't point to anything. So, setting the head to NULL, means that the list is empty. And, in printlist our temporary pointer starts at the head, and when it becomes NULL, we know we have reached the end of the list. If you don't initialize the head to NULL, then its value is uninitialized - it could be anything. So, most likely the seg fault is happening because we try to follow a bad pointer into unmapped memory.
I have a few questions. Some are probably more nitpicky stylistic preferences, but I'm wondering if there's a specific reason for them: * Why do typedef for the struct as a separate statement instead of together with the struct definition? * Why did you name it node_t instead of just node? * Why use underscores? I thought for compiled languages, CaML case tends to be standard. * What is the point of using a pointer to a pointer in some functions, but just a single pointer in others? * When you used malloc(sizeof(node_t)) why not cast it as (node_t*)malloc(sizeof(node_t)) ? Some of these questions are because after looking up various tutorials online, I seem to get conflicting information.
Mostly yes, just stylistic choices. The typedef I did separately, hoping to avoid some confusion from beginner students. As far as coding style, I've seen a lot of different styles over the years in different organizations and companies. Go with whatever style your company wants. As long as you're consisent and your code is readable, I personally don't think it matters much which one you use.
i was linking like this n->next = head and head->next = n and some weird bugs were happening i should be doing this n->next = head and then head = n i just wanna say thank you for saving me
At min 10:10, node value 32 is transfered to pointer tmp which is transferred to pointer head. Then new node value 8 is created tranferred to tmp which is again tranferred to pointer head. Should head and temp now both have value 8 ? Thx for help
great videos, you shouldve be my lecturer in printlist, what we actually doing in parameters and [node_t *temp = head; ]? i mean what does it mean, i dont really catch it
The idea is to use a temporary pointer to trace through the list. We start it at the head (the front of the list), and then follow the links until we reach NULL (the end of the list).
Amazinv ideo, thank you! I got a little confused when you created the create_new_node function, why does the function needs to be a pointer too? What do a pointer function exactly points at?
A warning to those who try to write the code as it’s shown: Blink and you’re dead
Great vid btw cheers
Thanks. Yeah, playing back at half speed might help.
Omg
Omg weeping angels run and don’t blink!
@@JacobSorber rushing in this case creates tiny mistakes, also it's easier to understand slower line-by-line when first introduced
@@JacobSorber I watch in 2x :)
NOW I know what pointers are used for in C!! Can’t imagine all the things you could do with them. That’s amazing! Thank you!
I know, right?
Pointers are also very handy for giving a function a pointer to some big data and you won't be moving as many variables
you can even develop hacking software for games using pointers in c++
I'm gonna have to watch this at half speed.... very dense with good info :)
Its actually very intuitive...
i watched it x2
@@thengakola6217 🙇🙇
@@neillunavat depending on how much exposure you've had, but hey take the time to feel good about yourself LOL
post your github, lets see your projects bud
I'm graduating in May 2021 and preparing for Leetcode and Hackerrank technical interview questions. Jacob, your explanation of how Linked Lists work, and the accompanying C implementation is extremely helpful. I mostly program in garbage collected languages like Python and Java, but after watching re-watching your videos and struggling with my compiler for a while, I feel like I finally understand how Linked Lists are implemented under the hood.
Hope you got your job bro
@@verbisdiablo Thank you! Yes I did get the job and really like it so far. I hope you are doing well.
@@verbisdiablo Thanks! Fortunately I did get the job and it's going well so far.
I gotta be honest all of this is great and all but if you're gonna use linked list a lot then implementing them each time will be such an exhausting and time wasting process so it's better that after you understood how they work that you create functions ready for use when ever you want so that you don't implement time every single time.
this honestly was the best way to explain the linked lists ,going from the basics and reaching the more complex functionalities ,
Thanks. Glad you enjoyed it.
Perfect demonstration that learning to program only in very high level languages such as Java, Python etc will always hide from you the elegant simplicity and beauty of data structures ...
5 minutes in and the explanation is already so helpful. Edit: After going beyond 5 minutes, the speed of his code isn't very convenient really.
Amazing video. I am taking an online programing course and for homework, i got stuck with trying to implement a linked-list in C. I understood the theory, but this video helped me see how to actually use it in code.
Amazing video. Very smart guy. I had to pause the video and write the code in pen for the first 10 mins until I saw what was happening.
Thank you very much.
"Oh Java i just love your quirks" is my life's motto now
Glad I could help. It's more positive than some of the other java-inspired life mottos.
One cool trick with linked list and arrays is instead of having a really long array, or a really long list, you have a linked list of pointers to multiple arrays. That way you can easily sort values into arrays without a single one getting too large.
That's a trie, isn't it?
This guy reminds me of my professor. Covers materials at 100 mph, then asks you got it? Understood? Good. Let's move on.
Me: Wha.....?
Nobody spoke up. So, I kept going. :)
Seriously, I do slow down in person, when I can gauge from student faces how things are sinking in. Fortunately, with RUclips you can replay and watch it at reduced speed.
@@JacobSorber haha true that. I do have difficulty understand some other pieces of the code though that weren't explained what it does. But overall I think better to understand than my professor.
Thank you so much! I struggled a lot with this, and you solved all my problems. Thank you for everything, man.
This Professor is brilliant. I love using your videos Jacob! They really lit up those areas of my brain that needed to grasp C. From a dull glow to a flashing glare! Thanks so much.
I have been coding in Python and Java for a couple years now, but C had always seemed very intimidating. I am glad I found your channel. Thank you
THE FIRST 30 seconds!! you called me out majorly lol. I was speaking with my prof about some confusion on an assignment (I'm a senior) and he said "well linked lists are something you know already from your intro classes so that part should be easy" I immediately clammed up out of embarrassment and now here I am. Thank you for making this video.
Your keyboard must be heaven to ASMR listeners.
makes me anxious af lmao especially when he stops talking, what a disgusting sound xd
I swear, this video better get 500k views at least.. mans explaining with ease
Thanks, Mauro! I'm glad you liked it.
Hello sir I'm from India.....I get this video by connecting vnp. So that, no video from my location shall not be in the search list......and I found you.....a great teacher.....thank you.....I'm subscribing you
Thank you so much I really appreciate the effort and patience you put into your videos , I have my exam tomorrow and I was struggling to understand the concept and it's implementation throughout the semester but your explanation came in handy and made things easier for me ; wish me luck 🤞
First time working with linked lists, this introduction felt really good!
Dude THANK YOU. You just made me understand pointers to pointers in a single line with that insert_at_head. I always thought it only served to pass arrays of pointers and chars
I wish I could learn this much thing every 18 minutes in my life
Thank you very much for the wonderful explanation. I would to add a function to free memory after we have used it.
void free_list(node_t *head)
{
node_t *tmp = NULL;
while (head !=NULL)
{
tmp = head; // Store the current head to tmp
head = head->next; // Move to the next node
free(tmp); // Free the current node
}
}
The pointer to the first node in the list is passed by value, so you don't need the temporary variable to print the elements in the list.
You are right. I tested it and had the same results
Thank you. I really like that you understand what you're talking about and it feels like you really enjoy programming, which makes it fun and easy to follow you.
Thank you for the video. I do have to say the portions where you actually write code are simply too fast for me. I am aware I can pause but I might have to pause every 2 seconds at some parts which gets tedious quickly.
Thank you very much for the video. Revised Linked list in 18 min. I have my interview tomorrow.
You're the best man ... Can you please make a video on struct node** head_ref and struct node* head_ref ? I'm just confused with double pointers in linkedlist.
Honestly this explain is better then my college professors but you code so fast! Thank you for explaining this better!
Thanks. Glad it helped.
I love the simplicity and implicity of the content which you created. G bless U
Thank you so much for making this awesome video, I got confused after going through a three-hour lecture. But this video just helps me solve that confusion within 30 minutes.
Hey, Jacob. Thanks for touching the structures. Tell us about more specific or less used structures as pyramid or quadtree. That would be great.
I agree, it can be really nice to have some videos about less common data structures.
You forgot to free up the dynamically allocated nodes.
The video was really helpful.
Thank you computer science Matthew McConaughey! This saved me on my project.
Hairless Matthew McConaughey just taught me a lot about coding. Thanks :3
Thanks, i would be awesome if your channel were there during my college :)
this is helpful and all but you don't have to fast forward; it makes it really hard to keep up with what you're doing
Please make more videos on data structures. Your videos are very easy to grasp. Thanks.
Thanks. I posted one today, and have a few more planned.
Thank you sooooooo much for providing such a high quality content for free on youtube
probably the only programming tutorial out there that has to be slowed down(playback speed!)
Simplest and clear singly linked list tutorial, I have seen till now. Cheers.
That sound while typing is super cool!
I'll say something & probably will get lambasted, I've been through 10 to 20 tutorials on DSA. I search DSA through C/C++ on RUclips and hundreds of subpar, half-arsed tutorials of incompetent people ( who possibly don't even know what they're doing ) pops up and it's so annoying because not only you've a problem that require DSA comprehension but now you also have another issue of finding a decent resource. I'm glad I found this channel amid heaps and piles of trash.
Thank You!
Welcome! Glad you found my channel.
@@JacobSorber ♥️
i swear to god literally make 3-4 hour long ASMR videos of you just coding whatever with that keyboard guaranteed 2 million views
Jacob Sorber's contents are just amazing.
HOLY CRAP I LOVE THIS VIDEO THANK YOU. The general concept just did not click in my head bit watching this video made me realise how it works it all makes sense now. Definitely subscribing just for that.
Your videos are fantastic. Thank you so much for sharing this knowledge in such a didactic way. Hope to be able to buy your course soon! 👏👏👏👏
I'm not sure if this is that best way to handle this, however in the video there was no code on adding a node to the end of the list so I came up with this. Where you pass in the head of the list and the create_new_node function. ex. insert_at_end(head, create_new_node(55));
void insert_at_end(node_t *head, node_t *newnode){
node_t *tmp = head;
while(tmp->next){
tmp = tmp->next;
}
tmp->next = newnode;
}
@4:20... Jacob's Ladder 🤣🤣
8:45 yes, I am indeed enjoying this video😁
I like that you are one of the only I have seen that type at the same speed as me
😂
@@JacobSorber I ask if you ever considered using rust instead of c and c++? In a comment on another of your videos. Just interested because i come From a language theory perspectiv so it is fun to hear the what you thought about it.
You are a beast at coding man, I'm a student at the school 42, I need to learn this data structure quickly for a project
Thanks. Make sure you don't just learn it quickly. Learn it well. That way you won't have to learn it again in a month or two. :)
Best of luck.
dang your keyboard sounds really good.. Also thanks for the java piece
Dude you're awesome. I'm trying to become a cs major and your videos help me out so much!
I think this is the simplest program of linked list, Thank you :)
what an underrated channel, thanks!
Thank you so much !! I didn't know how to manipulate my *head pointer well to find a node in my list for inst. This was so confusing but now i know better thanks to you :D
You're welcome. Glad I could help.
Thank you!! This video helped me so much
And that's how I understood linked list! Thanks a lot for the clear and concise explanation brother, keep the good work ;)
This is a great video, very grateful for the efort you put into this.
Thank you for this awesomely clear tutorial !
You're very welcome.
I really like the way you explain. Being a C developer and given the fact that linked-lists were uncharted areas for me, i found this really helpful.
In fact i fixed a bug in a piece of code at work that i had implemented. :)
It would be really interesting to see free memory malloced for the nodes, once you're finished with linkedLists work.
Thanks. I'm glad it was helpful.
I don't completely understand your request, though. Are you wanting to see how memory allocators work? Or are you looking for some variant on what I did here with my linked list?
@@JacobSorber actually a variant. You could show how the allocated memory can be freed, once the work with linkedlist has been completed. I would also typecast those mallocs like (node_t*)malloc since they return void* by default. :-)
sir i look first 3 minutes of this video and l i love you and yor channel thank for sharing your knowledge 🖤🖤🖤🖤🙏🏻🙏🏻🙏🏻🙏🏻
Thanks and welcome
thank you very much , your videos are so simple to understand yet so enriched with information and well explained details
i tried to save a linked list and to save in a binary file then reading it but i struggled a lot if make a video about this topic that would be great !!
Hi, can you also cover A* search in C? Specifically, how to use a linked list with A* to solve a 4x4 puzzle?
Awesome explanation! Subscribed!
Thanks and welcome
Super effective and just what I need. You are my favourite teacher from now on.
Thanks! Let me know if there are topics you want to hear more about.
Thanks for sharing, bro!😄😄
Very good tutorial. Quick but also full of information. I like it that it isn't so slow that you can fall asleep. It motivates to stay in focus. :D
Great editing on the video, very well done on explaining this concept and presenting this video in a nice format! Thanks mate :)
Simple, informative, easy to understand
Very nice tutorial
thank you very much. It is really helpfull
very helpful, thanks
thanks for explaining all of this so succinctly
You're welcome.
Very good explanation. Thank you!!!
Thank you so much, Sir! That was a great video!!!!
In my career as a HPC programmer, I only used a linked list once. That was 8 years ago, before I found out that a simple array is 1000x faster.
And then I found out that you can get another 100x speedup on GPU with OpenCL.
As much as I like programming concepts, data structures like linked lists are inefficient nonsense. And sadly most computer science students never learn optimization, so their software runs slow like molasses.
you need them for interviews.. apparently
the sound of keyboard is awesome
Glad you liked it.
Thank you very much, your video helped me a lot
A different approach would be to create a Node constructor and pass in the data there. So you could write something like
// Node could be static?
static class Node {
Node next;
int data;
public Node(int data) {
this.data = data;
}
}
// Part of the Linked List class
public void add(int data) {
Node newHead = new Node(data);
newHead.next = head;
head = newHead;
}
Each their own approach I suppose, this is just another option for anyone who's interested. Learned this approach from a HackerRank video for anyone interested.
Thanks. Yes, having a constructor on the node, and pulling it out of the Linked List class is definitely an option. It really depends on the abstraction you want.
love it thanks, could even build trees with this
one of the best videos about linked lists. enjoyed it although i'm not new to this topic. would've liked a little bit big-o-notation though.
and - some addition to the still outstanding content - i think calling them 'chains' instead of lists would be more intuitive.
I liked your video, but I will suggest you to use StringBuilder instead of concantenating strings in Java.
Thanks.
You do a great job! Thanks.
That was super helpful...:)
Awesome!
Hi, thank you so much for your video, I'm just a beginner to programming and C.I was following you step by step and understanding every line you wrote, but when it came to the part of the for loop, I don't understand why the head value has to be initialized in 'NULL' for the printlist function to work, I just realized that if I don't assign that value to the head pointer I get an error "segmentation fault core dumped". If the list is created, I printed out the head value and I obtain 24, why the function does not work. I tried to read about the error but I still don't understand it. Thank you so much again.
I'm not 100% sure I completely understand the question, but we're using NULL to mean that a pointer doesn't point to anything. So, setting the head to NULL, means that the list is empty. And, in printlist our temporary pointer starts at the head, and when it becomes NULL, we know we have reached the end of the list. If you don't initialize the head to NULL, then its value is uninitialized - it could be anything. So, most likely the seg fault is happening because we try to follow a bad pointer into unmapped memory.
I have a few questions. Some are probably more nitpicky stylistic preferences, but I'm wondering if there's a specific reason for them:
* Why do typedef for the struct as a separate statement instead of together with the struct definition?
* Why did you name it node_t instead of just node?
* Why use underscores? I thought for compiled languages, CaML case tends to be standard.
* What is the point of using a pointer to a pointer in some functions, but just a single pointer in others?
* When you used malloc(sizeof(node_t)) why not cast it as (node_t*)malloc(sizeof(node_t)) ?
Some of these questions are because after looking up various tutorials online, I seem to get conflicting information.
Mostly yes, just stylistic choices. The typedef I did separately, hoping to avoid some confusion from beginner students. As far as coding style, I've seen a lot of different styles over the years in different organizations and companies. Go with whatever style your company wants. As long as you're consisent and your code is readable, I personally don't think it matters much which one you use.
Brilliant tutorial, thanks a lot!
You're very welcome!
i was linking like this n->next = head and head->next = n and some weird bugs were happening i should be doing this n->next = head and then head = n
i just wanna say thank you for saving me
Glad I could help.
very good video! very easy to understand
do you have courses with reasonable prices on c language ?
i like how you explain i understand everything
At min 10:10, node value 32 is transfered to pointer tmp which is transferred to pointer head. Then new node value 8 is created tranferred to tmp which is again tranferred to pointer head. Should head and temp now both have value 8 ? Thx for help
Great video
Thanks, Mike.
This is awesome!
Pretty neat!
Thank you
You're welcome. Glad you enjoyed it!
Sir, Thank you.
thanks bro it was really help full for me
You're welcome. Glad it helped
great videos, you shouldve be my lecturer
in printlist, what we actually doing in parameters and [node_t *temp = head; ]?
i mean what does it mean, i dont really catch it
temp is a pointer who could point to something of data type node_t. And here it points towards head.
@@joethomas2355 so we usually create [int *temp], now we could make "data type" [node_t * temp],
which head we pointing?
The idea is to use a temporary pointer to trace through the list. We start it at the head (the front of the list), and then follow the links until we reach NULL (the end of the list).
Amazinv ideo, thank you! I got a little confused when you created the create_new_node function, why does the function needs to be a pointer too? What do a pointer function exactly points at?
idk im fucking dying fuck im gonna die