@Brian Faure. Thanks for your tutorial. I really appreciate for your efforts to make this tutorial. After watching your vedio , I am confused by one thing. The append function doesn't show the great advantage of the linked list. Could you give us more explanation about this. I think one great merit for linked list is: when we want to insert a node into the list, it just need to change the pointer instead of moving the items in the list to create an gap and then inserting the new item into the list. In the linked list, when we want to insert an node, we just need to change two pointers, which helps us save time, especially the list contains millions of node. But your append function, it needs to iterate to find the last node and then add a new node. This doesn't show the virtue of the linked list. So I am think about the append function whether we could just add the new node at the end of the linked list without iteration. Thanks for your help.
Hi Xiufeng, thanks for the nice words! Yes the way the append function works currently is O(n), and is not the most efficient. By adding in an extra class member variable, we can call 'tail' for example, we can reduce the complexity of the append function down to constant time, or O(1). A possible implementation could be as follows: > def append(self,data): > new_node=node(data) > self.tail.next=new_node > self.tail=new_node Take note that for this to work, we will need to declare this 'tail' variable in the constructor of the class: > def __init__(self): > self.head=node() > self.tail=self.head If you wish to take this approach, you'll also need to be careful to set the 'tail' correctly inside of the 'erase' function (for example, if you try to erase the last element in the list, you'll need to set the tail to the _new_ last element). The following 'erase' function includes a single 'if' statement which should achieve this: > def erase(self,index): > if index>=self.length() or index print "ERROR: 'Erase' Index out of range!" > return > cur_idx=0 > cur_node=self.head > while True: > last_node=cur_node > cur_node=cur_node.next > if cur_idx==index: > last_node.next=cur_node.next > if last_node.next==None: self.tail=last_node ## *Here is where we set the tail* > return > cur_idx+=1 I've done some simple tests with this new implementation and it seems to be working, but feel free to let me know if you find any issues or have any other questions! I'm going to pin this comment so any others with the same question can see it.
Hello, I have a question about the way you append new object with self.tail: why setting both self.tail and self.tail.next equal to next_node. Does this mean you set the last element (after the tail) equal to the new node and then set the tail of the list to that node?
I was a beginner and struggled a lot for the right content and pace which suited me. I have started watching your videos and I must say the concepts are taught very well. At most places I see people just giving presentation through slides and your videos teach us how to implement them. My request to you is to please put more videos in this very playlist covering topics such as Heaps, Recursion etc . Basically the topics which you have'nt uploaded here. You're doing a great job sir. Your efforts can make someone's career. Someone like me. Thank you and have a nice day !
I love you dude thanks for explaining this stuff so clearly. So many other channels explain this stuff so badly, but you make it so easy to understand.
I know this is more geared to beginners but a better way to do length for an object is by levying your own dunder method or "magic method". You can do this by defining your function as: def __len__(self): this will let you leverage the length of your linked-list by using len(your_linked_list) rather than using your_linked_list.length(), which will be more pythonic and user friendly. You could also use def __getitem__(): for yor get function.
Thank you for making this great tutorial, it's very helpful! I've been struggling with understanding the linked list structure and finally find answers from your video, thank you very much!
Thank You Brian. this video was very helpful. i watched other tutorials and they were confusing. one thing I discovered about algorithm and data structure is that the teacher's use of plain english and well outlined variable is fundamental to understanding the concept easily. i grasped everything you taught in this video but the challenge i face is that once i try to implement it on my own, i run into errors because i don't like the idea of copying people's code rather than either interpreting in a paper or typing them on my own. i have fundamental knowledge of programing and am a web developer. i want you to help me master OOP, DSA and Iterations. Thank You
no, becuase if you increment the index before the if statement the index will always start at 1 not 0 so the my_list.get(0) will be None, but if you increment it after the if statement, it will check the index 0 first and the get(0) method will return the first elem if it makes sense. basically if you have it before the if statement, your linked list will always start with index 1 not 0
Good job making this video. - append() method and elems.append() might be confusing if you create a method to insert at end with name other than append().
I found the concept interesting, I'm not sure where I'd use it over a list. I must say that your code can be made much more efficient by adding a _length variable and incrementing it when you append and de-incrementing it when you erase. No need to iterate when you can store it in an integer. Also __repr__() could be used vs display or perhaps a __str__(). so you could just print(linked_list) __getitem__() or perhaps __get__() could be used so you could linked_list[0] magic methods are kinda cool.
Really dumb question, but in the display method why is cur = cur.next before elems.append? In my head you would want to append to elems first and then move the pointer
Thank you for making such a great tutorial! It really helps me aces the linked list, which I kept avoiding before. Finally found your clear step by step tutorial! It is so cool and excellent, thank you!
Instead of doing another costly iteration through the linked list to find the size of it. We can add a self.length variable to the init() with an initial size of 0, and then add a 1 in the append() and a subtract a 1 in the remove method
For the length method, should total + 1 not be returned since the last node won't be added to the total (because it doesn't satisfy the condition of the while loop)?
It would be simpler if when you append a new node, you simply point it to the head node and set the head as the node you just added. Saves you from iterating through all the nodes you've added (could be a large number) to add one to the end.
I have a doubt. In the "append" method, new_node = node(data), each time The append method is called, an object of node class is created with the same name (new_node). Why doesn't this produces an error? wouldn't the object be garbage-collected?
Hi, this isn't an issue because the Python garbage collector uses reference counting to decide what to remove from memory and since we are setting the 'next' node pointer of the prior node equal to this node there will always exist some reference to it (until it is deleted from the list).
I had the same error. It's possible that in your length() function you are printing the total, instead of returning it. self.length() needs to RETURN a value, not PRINT
That would be the case if the self.head node actually contained data but with this approach we use the self.head node simply to point to the first true node in the list, thus we don't need to worry about printing its content. Thanks for commenting!
Thanks for this video, you've explained the code and data structure really thoroughly and I'm starting to understand the implementation of LinkedLists. However, I found a bug with the length method that you wrote in the video. I found that if you try to access the last element of LinkedList it will raise the error due to the count starting at 0 rather than 1. The fix is simply start the count at 1 because it counts the empty node and makes the final element inaccessible via the get method that you defined. Also, with the change above, you want to move the `if cur_index == index: return cur_node.data` statement to the top of the while loop or you'll get an error stating cur_node.data is None (the get method)
Awesome! But in method for calculate length I see some sort of problem. If counting start from 0 - head will not count. I understand, that list index start from 0, but in length method 0-element must counting like another 1. Or this is mistake?
It's the default Ubuntu terminal color scheme with some extra background opacity ( askubuntu.com/questions/941734/whats-the-rgb-values-for-ubuntus-default-terminal-unity ). If you're on Windows 10 you can actually install the Ubuntu terminal directly and take advantage of all it's sweet features (and also the color scheme), there's some info on that here docs.microsoft.com/en-us/windows/wsl/install-win10 . Otherwise if you're on a lower version of Windows you can install Cygwin and customize the color scheme to look like this in the appearance settings. Similarly if you're on OSX or another Linux distro you'll have to tweak the appearance settings to match.
I have a doubt.. If there is only one element say 5... Self. Data is 5 and self.next= none right?.. When you run "length" loop..the cur.next is equal to none, so it comes out and gives the length as 0...but the length should be 1 right?
I don't understand one thing.. in your functions, you repeatedly used a loop comparing to 'cur.next' but never initialized its value. What does it initially make its comparison to, before entering the loop? (example, line 15. while cur.next!=None)
and even if 'cur' replaces 'self' in the node class, we already initialized it as 'None'. So how will we enter the loop, as cur.next IS equal to None in the first place? Thanks for the hardwork btw
I think you got the initialization part, the 'next' value of the 'node' class is initialized in the 'node' class constructor to a default value of None, so when we say 'cur=self.head', we're setting 'cur' equal to an instance of the 'node' class, whose 'next' value was set to 'None' by default (this value of 'None' is changed once we insert a single item). For the 'while' loop on line 15, if there isn't anything already in the linked list (the length is 0) then we will pass straight over the loop (won't even do a single iteration) because 'cur.next' WILL equal None, obviously, in this case this will no longer be true after a single call because, since we're appending on an item, the 'next' value will no longer be 'None' but will instead be set equal to another instance of the 'node' class. Lemme know if this clears it up at all.
At 11:50 I think it should be if index > self.length() instead of index >= self.length() This will ignore the last element and it cannot be accessed. I am still a newbie, correct me if I am wrong. Anyway, great series, thank you sir
Python list index start from 0 while .length() return how many data is inside the list. Say I have this list... list = [1, 2, 3, 4, 5] The max index is 4, because the first address started from 0. list[0] = 1 list[1] = 2 list[2] = 3 list[3] = 4 list[4] = 5 See how the last index is 4. If you try to print the same list using list.length(), it will return 5 as there is a total of 5 data inside the list. If you do index > self.length(), it would make it possible for the user to try to return list[5], which is non-existent as the max index is only 4.
In the erase() we are just removing the pointer to the element that we dont want..But the element that we want to delete is still in the memory and occupies space for no purpose??😕😕
Hi Sarah, in Python if there aren't any references to an object (if it can't be accessed from the code any longer) the garbage collector should deallocate the memory associated with the object. You can read more about this if you google for 'python garbage collection' but this is a pretty good resource: rushter.com/blog/python-garbage-collector/
This gets the idea of a linked list. However, it's not a very efficient implementation. With that append method you'd be iterating the WHOLE linked list before each insertion, and avoiding that kind of insertion is the very reason of using a Linked List. This could be easily fixed by keeping track of the Linked List's tale node.
I think it works. In the len function it is technically counting the head which doesn't have data and not counting the last node. I believe it works as he intended though.
You use function naming convention for your classes which would become very confusing eventually especially for new people. For example instantiating a class would look identical to assigning a function to a variable.
The video was really helpfull.I have one doubt.In c the head pointer points at the first node.Here too it does that but it is also a node right?So the first node of the linked list will be the head?Am i correct?
I got it right? When we implement the erase function we're actually just changing pointers and that's it? So the object is still in memory and we're just go through it when we display all elements?
Hi Roman that is correct except in Python when we remove all pointers/references to an object the “garbage collector” effectively erases it from memory for us!
@Brian Faure. Thanks for your tutorial. I really appreciate for your efforts to make this tutorial. After watching your vedio , I am confused by one thing. The append function doesn't show the great advantage of the linked list. Could you give us more explanation about this. I think one great merit for linked list is: when we want to insert a node into the list, it just need to change the pointer instead of moving the items in the list to create an gap and then inserting the new item into the list. In the linked list, when we want to insert an node, we just need to change two pointers, which helps us save time, especially the list contains millions of node. But your append function, it needs to iterate to find the last node and then add a new node. This doesn't show the virtue of the linked list. So I am think about the append function whether we could just add the new node at the end of the linked list without iteration. Thanks for your help.
Hi Xiufeng, thanks for the nice words! Yes the way the append function works currently is O(n), and is not the most efficient. By adding in an extra class member variable, we can call 'tail' for example, we can reduce the complexity of the append function down to constant time, or O(1). A possible implementation could be as follows:
> def append(self,data):
> new_node=node(data)
> self.tail.next=new_node
> self.tail=new_node
Take note that for this to work, we will need to declare this 'tail' variable in the constructor of the class:
> def __init__(self):
> self.head=node()
> self.tail=self.head
If you wish to take this approach, you'll also need to be careful to set the 'tail' correctly inside of the 'erase' function (for example, if you try to erase the last element in the list, you'll need to set the tail to the _new_ last element). The following 'erase' function includes a single 'if' statement which should achieve this:
> def erase(self,index):
> if index>=self.length() or index print "ERROR: 'Erase' Index out of range!"
> return
> cur_idx=0
> cur_node=self.head
> while True:
> last_node=cur_node
> cur_node=cur_node.next
> if cur_idx==index:
> last_node.next=cur_node.next
> if last_node.next==None: self.tail=last_node ## *Here is where we set the tail*
> return
> cur_idx+=1
I've done some simple tests with this new implementation and it seems to be working, but feel free to let me know if you find any issues or have any other questions! I'm going to pin this comment so any others with the same question can see it.
Hello, I have a question about the way you append new object with self.tail: why setting both self.tail and self.tail.next equal to next_node. Does this mean you set the last element (after the tail) equal to the new node and then set the tail of the list to that node?
Can you make more I love yours do you have stuff on graphs or heaps or merge sort
So Chinglish
I struggled a lot with DSA until I found this channel. Now I struggle a lot less thanks to you.
3:40 node class, 5:00 linked list class, 6:12 linked list-APPEND method, 7:55 linked list-get LENGTH method, 9:22 linked list-DISPLAY LIST method, 11:31 linked list-get DATA method, 14:50 linked list ERASE method
THANK YOU
Thanks for the timestamps man! It was really helpful!
5 years later and this is still a great video! Awesome in-depth explanation.
+ 5 months! Stil great
I was a beginner and struggled a lot for the right content and pace which suited me. I have started watching your videos and I must say the concepts are taught very well. At most places I see people just giving presentation through slides and your videos teach us how to implement them. My request to you is to please put more videos in this very playlist covering topics such as Heaps, Recursion etc . Basically the topics which you have'nt uploaded here. You're doing a great job sir. Your efforts can make someone's career. Someone like me. Thank you and have a nice day !
This man deserves an award for how well he broke down every concept!
I have searched through RUclips to find someone to explain Linked lIsts and I gotta say, your video was the most helpful. Thank you so much!
Glad to hear it helped you, thanks for watching Austin!
Agree. The current appending solution is O(n) not O(1). Your solution should be O(1), which is the benefits of using Linked List
.
i must say, this is the simplest coding of linked list i've seen so far on the internet
Lolll, this is the most general and common code for linked list.
Your explanation is too clean and lucid.Thanks for a great video!
I'm a beginner at coding and this was very helpful. I also liked the cadence of your voice, it helped me from not zoning out. Keep it up!
I love you dude thanks for explaining this stuff so clearly. So many other channels explain this stuff so badly, but you make it so easy to understand.
Thank you so much for this! This is just what I needed to understand linked lists properly!
I know this is more geared to beginners but a better way to do length for an object is by levying your own dunder method or "magic method". You can do this by defining your function as: def __len__(self): this will let you leverage the length of your linked-list by using len(your_linked_list) rather than using your_linked_list.length(), which will be more pythonic and user friendly. You could also use def __getitem__(): for yor get function.
I searched for python linked list and watch many tutorials but I found this tutorial is best.
expect more python tutorials from this channel.
beleive me you are one of the greatest teacher of coding. oh its true ,,,its dammmnnn true... keep it up.
Thanks so much!
yes its good
What Kurt Angle would say if he was a developer haha
Best explanation ever please never stop making great videos, we will subscribe
Excellent video, really clear, direct, concise and easy to follow. Amazing, so many people on RUclips need to learn a thing or two from you.
Extremely helpful tutorial! Clear, concise presentation. And Python is also my favorite language!
You're a great tutor! This feels like it brings me closer to where Python will finally "click" with me.
Thanks so much!
Its 2022 still the best linked list video on python
Thank you for making this great tutorial, it's very helpful! I've been struggling with understanding the linked list structure and finally find answers from your video, thank you very much!
First dsa video! the keyboard sound was just 🤩
I love your tutorials. I wish I could have discovered them before starting CS110 three months ago. Keep up the great work
Thank You Brian. this video was very helpful. i watched other tutorials and they were confusing. one thing I discovered about algorithm and data structure is that the teacher's use of plain english and well outlined variable is fundamental to understanding the concept easily. i grasped everything you taught in this video but the challenge i face is that once i try to implement it on my own, i run into errors because i don't like the idea of copying people's code rather than either interpreting in a paper or typing them on my own. i have fundamental knowledge of programing and am a web developer. i want you to help me master OOP, DSA and Iterations. Thank You
awesome man thank you. Been having trouble with data structures but this seriously helped a lot.
I have an error on display function it's say that 'None type' object has no attribute 'data'
antipop to the mic and this is gold. thanks a lot.
I love your tutorial video. Excellent presentation. Very clear explanation. 2 thumbs up.
I looked for copper but found diamond. Loved the video, will help me with my exam.
Thanks needed a quick refresher on linked list. Going to see if you have double linked list now...thanks again
my_list = LinkedList()
my_list.append('3 years later but still great, thanks Brian')
my_list.display()
16:42 and a few of other spots, shouldn't we be incrementing the cur_idex by one before the if statement?
no, becuase if you increment the index before the if statement the index will always start at 1 not 0 so the my_list.get(0) will be None, but if you increment it after the if statement, it will check the index 0 first and the get(0) method will return the first elem if it makes sense. basically if you have it before the if statement, your linked list will always start with index 1 not 0
@@codeityourself4847 thank you so much!
@@emilyli6763 you are welcome
thank you for explaining the erase method, I was confused from another video on how the element gets deleted by just assigning the last node
Your channel is gold
Good job making this video.
- append() method and elems.append() might be confusing if you create a method to insert at end with name other than append().
Thgank for the tutial as suggestion for future video. How to choose a Data structure? Pros vs Cons. Speed Big O notation
Best video on the topic
Great content Brian. Thank you.
Thank you. i know i can watch the video again and understand it
I found the concept interesting, I'm not sure where I'd use it over a list. I must say that your code can be made much more efficient by adding a _length variable and incrementing it when you append and de-incrementing it when you erase. No need to iterate when you can store it in an integer. Also __repr__() could be used vs display or perhaps a __str__(). so you could just print(linked_list) __getitem__() or perhaps __get__() could be used so you could linked_list[0] magic methods are kinda cool.
Really dumb question, but in the display method why is cur = cur.next before elems.append? In my head you would want to append to elems first and then move the pointer
yeah the same question and he also wrote in the same style in the get fuction . It has been 4 years and do u know why ?
Thank you for making such a great tutorial! It really helps me aces the linked list, which I kept avoiding before. Finally found your clear step by step tutorial! It is so cool and excellent, thank you!
i just wasted 2 hours too complete this get method finally thanks
Great video. On your erase, I think it is essential to reassign the self.head for when erase is called at index= 0 so that it does not stay as None
Thank u for making this video, neat code and clear explanation, 10/10. I really hope one day I can be as intelligent as you are.
Very useful, I'm in gr 11 and learning this it was well explained!
Just wanted to add that the Doubly Linked List also has access to the last node, or the tail. Where the Singly Linked List doesn't.
Instead of doing another costly iteration through the linked list to find the size of it. We can add a self.length variable to the init() with an initial size of 0, and then add a 1 in the append() and a subtract a 1 in the remove method
Thanks, Brian. Really helpful.
This makes sense. My prof should not be teaching, haha. Thanks for explaining while making it so concise.
Fantastic explanation of the topic, thank you!
Really Useful keep on doing more videos please
For the length method, should total + 1 not be returned since the last node won't be added to the total (because it doesn't satisfy the condition of the while loop)?
The length function is wrong, you need to add 1 to account for the last node.
The head node(empty node at the start) will count towards the total so it kinda cancels out
It would be simpler if when you append a new node, you simply point it to the head node and set the head as the node you just added. Saves you from iterating through all the nodes you've added (could be a large number) to add one to the end.
Pretty silly statement. I think in general terms when you "append" to a list, you are specifically adding to the end of the list not to the beginning.
8:36 I think While should be cur != None, if we use while cur.next != None it will get length - 1 of total
Yeah!
I think in that way too. Indexing start from 0, but size counting - from 1
Great video dude, it helped me a lot!
at 16:50, why does current node need to be equal to self.head? whats the point of this?
Because you want to start at the first index of the list since your idx=0.
@Brian Faure, Your explanation is pretty awesome. But, I think you have missed the "insert" operation.
I have a doubt. In the "append" method, new_node = node(data), each time The append method is called, an object of node class is created with the same name (new_node). Why doesn't this produces an error? wouldn't the object be garbage-collected?
Hi, this isn't an issue because the Python garbage collector uses reference counting to decide what to remove from memory and since we are setting the 'next' node pointer of the prior node equal to this node there will always exist some reference to it (until it is deleted from the list).
@@BrianFaure1 Thank you. That clears my doubt.
What textbook are the screenshots from? For example at time stamp 3:25
especially 3:26 and 3:27
Man !This is so crisp ! Nice tutorial
hi @brian,
getting error on if check
if index >= self.length():
TypeError: '>=' not supported between instances of 'int' and 'NoneType'
I had the same error. It's possible that in your length() function you are printing the total, instead of returning it. self.length() needs to RETURN a value, not PRINT
Great video, thanks for the post.
This video is very helpful for me to understand the linked list. I thought it would be very complicated 🤔
10:24 shouldn't the elems.append switch position with the line above so that the display function could also print out the first node?
That would be the case if the self.head node actually contained data but with this approach we use the self.head node simply to point to the first true node in the list, thus we don't need to worry about printing its content. Thanks for commenting!
Great work. Really appreciated
Thanks for this video, you've explained the code and data structure really thoroughly and I'm starting to understand the implementation of LinkedLists.
However, I found a bug with the length method that you wrote in the video. I found that if you try to access the last element of LinkedList it will raise the error due to the count starting at 0 rather than 1. The fix is simply start the count at 1 because it counts the empty node and makes the final element inaccessible via the get method that you defined.
Also, with the change above, you want to move the `if cur_index == index: return cur_node.data` statement to the top of the while loop or you'll get an error stating cur_node.data is None (the get method)
Awesome!
But in method for calculate length I see some sort of problem.
If counting start from 0 - head will not count. I understand, that list index start from 0, but in length method 0-element must counting like another 1. Or this is mistake?
>> cur = self.head
it started from head
>> while cur.next!=None: > idx+=1
For the length method, can't you just initialise a length variable and +/-1 to it everytime u add/delete a node?
Yes, and that would certainly be more efficient in most use cases. Thanks for watchin!
Great video! Thanks for your work!
Awesome video..👌👌
One of the best I've seen for python tutorials.👌
Thank you sir..It was very informative.
What colour scheme did you use for your command line? I'd like to switch my terminal to that colour scheme
It's the default Ubuntu terminal color scheme with some extra background opacity ( askubuntu.com/questions/941734/whats-the-rgb-values-for-ubuntus-default-terminal-unity ). If you're on Windows 10 you can actually install the Ubuntu terminal directly and take advantage of all it's sweet features (and also the color scheme), there's some info on that here docs.microsoft.com/en-us/windows/wsl/install-win10 . Otherwise if you're on a lower version of Windows you can install Cygwin and customize the color scheme to look like this in the appearance settings. Similarly if you're on OSX or another Linux distro you'll have to tweak the appearance settings to match.
I have a doubt.. If there is only one element say 5... Self. Data is 5 and self.next= none right?.. When you run "length" loop..the cur.next is equal to none, so it comes out and gives the length as 0...but the length should be 1 right?
cur = self.head
cur.next = None
I don't understand one thing.. in your functions, you repeatedly used a loop comparing to 'cur.next' but never initialized its value. What does it initially make its comparison to, before entering the loop? (example, line 15. while cur.next!=None)
and even if 'cur' replaces 'self' in the node class, we already initialized it as 'None'. So how will we enter the loop, as cur.next IS equal to None in the first place? Thanks for the hardwork btw
I think you got the initialization part, the 'next' value of the 'node' class is initialized in the 'node' class constructor to a default value of None, so when we say 'cur=self.head', we're setting 'cur' equal to an instance of the 'node' class, whose 'next' value was set to 'None' by default (this value of 'None' is changed once we insert a single item). For the 'while' loop on line 15, if there isn't anything already in the linked list (the length is 0) then we will pass straight over the loop (won't even do a single iteration) because 'cur.next' WILL equal None, obviously, in this case this will no longer be true after a single call because, since we're appending on an item, the 'next' value will no longer be 'None' but will instead be set equal to another instance of the 'node' class. Lemme know if this clears it up at all.
Your insertion takes O(n) time where time for Linked Lists are O(1)
So the head of the linked list is a node that doesent have data and only have next?
@Brian Faure. Thanks for your tutorial.
Super good explanation!
Excellent Explanation Sir
What's the difference between using != and 'is not'?
a != b is to check if a and b are not equal in values and "a is not b" is to check if a and b are not the same object (same memory address).
@@MrCk0212 Oh, I see. So when comparing to 'None' we would use 'is not'? Thanks
At 11:50
I think it should be
if index > self.length()
instead of index >= self.length()
This will ignore the last element and it cannot be accessed.
I am still a newbie, correct me if I am wrong.
Anyway, great series, thank you sir
Python list index start from 0 while .length() return how many data is inside the list.
Say I have this list...
list = [1, 2, 3, 4, 5]
The max index is 4, because the first address started from 0.
list[0] = 1
list[1] = 2
list[2] = 3
list[3] = 4
list[4] = 5
See how the last index is 4.
If you try to print the same list using list.length(), it will return 5 as there is a total of 5 data inside the list.
If you do index > self.length(), it would make it possible for the user to try to return list[5], which is non-existent as the max index is only 4.
In the erase() we are just removing the pointer to the element that we dont want..But the element that we want to delete is still in the memory and occupies space for no purpose??😕😕
Hi Sarah, in Python if there aren't any references to an object (if it can't be accessed from the code any longer) the garbage collector should deallocate the memory associated with the object. You can read more about this if you google for 'python garbage collection' but this is a pretty good resource: rushter.com/blog/python-garbage-collector/
@@BrianFaure1 Thanks man
This gets the idea of a linked list. However, it's not a very efficient implementation. With that append method you'd be iterating the WHOLE linked list before each insertion, and avoiding that kind of insertion is the very reason of using a Linked List. This could be easily fixed by keeping track of the Linked List's tale node.
for the len function, i think u should use curr instead of curr.next for the loop. Your code will give len -1 for the result
I think it works. In the len function it is technically counting the head which doesn't have data and not counting the last node. I believe it works as he intended though.
@Brian Faure You did great tutorial. I really enjoyed the tutorial.
Thank you sir.It helped a lot.Keep posting videos
You use function naming convention for your classes which would become very confusing eventually especially for new people. For example instantiating a class would look identical to assigning a function to a variable.
Awesome tutorial! Thank you
Fantastic explanation! Thanks!
THANK YOU really!!!
The only thing I can't understand is the % right before my_list.get(). What does it do exactly?
The video was really helpfull.I have one doubt.In c the head pointer points at the first node.Here too it does that but it is also a node right?So the first node of the linked list will be the head?Am i correct?
thank you for this tutorial it is simple and helpful
Can't we just say while current != None (or while current)? we dont necessarily need to make sure we have 2 nodes before null right?
I got it right? When we implement the erase function we're actually just changing pointers and that's it? So the object is still in memory and we're just go through it when we display all elements?
Hi Roman that is correct except in Python when we remove all pointers/references to an object the “garbage collector” effectively erases it from memory for us!
@@BrianFaure1 Thank you
Thanks for your wonderful tutorial.
I was stuck in the linked list part from about a week .
You were awesome
Thank you so much! Your explanation really helped!
Thank you very much Brian! You videos are really amazing and helped me a lot! i really appreciate for all your effort! Just can't thank you enough!
No problem, thanks for watching Jingyu!