Python: Linked Lists Explained | implementation, insert, delete nodes

preview_player
Показать описание
An overview of linked lists and how to implement one in Python. How to insert and remove/delete nodes explained.

PYTHON LINKED LISTS

Рекомендации по теме
Комментарии
Автор

Congratulations, it is the clearest way I've seen these explained. And I looked at a lot of videos 😃🤣

alexandrapetrache
Автор

excellent information, it is hard to find someone willing to explain these data structures line by line in actual python code.

chaderdwins
Автор

Thank you for the clear explanation. This gave me a good insight into nodes and linked lists and definitely increased my enthusiasm for both.

mattlarsen
Автор

Thanks for explaining it line by line.

dhriti
Автор

this is very helpful especially for a beginner. code is clearly explained. thanks a lot

pradeepprakash
Автор

Clear explanation on every line of the codes

Xennon
Автор

Great tutorial! I was getting angry at the people who called your shorter video rushed (it was great as well) but I didn't realize I needed this one as well! So thanks for taking the time to do this :)
Couple of quick questions, if I want to see the items in my linked list how would I do so? vars(myLinkedList) or myLinkedList.___dict___ just show a function (I think it's Node()) and the size; I think we'd have to create a function that loops and grabs 'd' and puts it in a list to see them. Please tell me there's a better way than that though...


Also, the add_node function (in your github page, LinkedList 1 and 2) doesn't work...this is what the console shows:
n.set_next(self.root);
AttributeError: 'int' object has no attribute 'set_next'
I get the error, but I don't know how to fix it. Can you fix the code?
Thanks for making this, it really helped me understand Linked Lists, especially with the cool animations! Have a great day!!

elsicongru
Автор

Hi Joe, great video. The add method for the linked list. The new node taken as root should also have his next node property set to the next node of the former root so that the new root points to the next node of the linked list. I hope that I am not mistaken. Thanks.

bardamu
Автор

find function of LinkedList should return the node that have the number or None for everything else. And another function as exist_data would be necessary.

soldadopreciso
Автор

great explanation, great effort. I am a java developer

subramanianchenniappan
Автор

Thanks heaps Joe! This helped much, I understand it much better! subscribed

Juceeass
Автор

Excellent video, thank you for the tutorial!

flamingbull
Автор

How will you delete one and only node in the list ? and in remove function size-1 only takes place only in else part ?

MukeshKumar-qxyg
Автор

Sort : In Python is no pass by reference then how we code merge sort which is best option to sort linked list
Merge sort
Split function
1. We search for middle node That node will be the tail node of left list
Here we have two options
a) Left list can be one node shorter (this happens if list has odd length)
b) Left list can be one node longer (this happens if list has odd length)
2. We set heads of our destination lists
3. We break the left list
In languages like Pascal or C++ arguments can be passed by reference but in Python not so how can we write this code ?
Merge function
1. We check if at least one list is empty
2. We compare key values in heads of our source lists to be able to set head of our destination list
3. While we not traverse at least one list
compare key value of current nodes
4. Concatenate list that is not traversed
If we use dummy node two first steps will not be necessary
Sorting function
If we have more than one node on the list
Split the linked list into halves
Sort each half recursively
Merge sorted halves
Other function looks similar to these for arrays if we use tail_insert auxiliary function

holyshit
Автор

Very nice...Subscribed man :) Thanks for help

shyamkushwaha
Автор

for the remove method in the Linked List class. How come you have to use "return True" inside the nested if statement, and "return False" for the outer if statement?

Kingofqueers
Автор

thanks pal, joe what about a empty LinkedList called my_ll and then execute print(my_ll.find()), it return None . 7:06 -- 7:44

soldadopreciso
Автор

Hi Joe, thanks for the video, learning a lot... I have a question, should we initialize self.size to 1 if a root is passed in? I understand that it should be zero if root is None. Lmk, thanks and great video :)

Mrdisaster
Автор

In what kind of situations would a linked list be useful?

warbirdk
welcome to shbcf.ru