Python: Sorting a Linked List

preview_player
Показать описание
This tutorial shows how to sort a Linked List, putting the nodes in sorted order.

PYTHON LINKED LISTS

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

you are not sorting a linked list, you are sorting a list.

failaimy
Автор

but then cant we sort it without using any extra memory(list)

nishitadash
Автор

I think that better idea would be to write own merge sort function
without copying Link list data to built-in list
function to reverse the order can also be useful if we want to sort in both directions

holyshit
Автор

That ruins the runtime though. This isnt really sorting a linked list

adamcunningham
Автор

Great video. Helped out a lot. I have just a few questions:

Why did you return a new linked list?
Couldn't you just have reversed the list storing data and then popping to rewrite the values in the nodes?
Or was it because you wanted not only to copy and paste data, but rather, the entire nodes?

StarFoxZX
Автор

Do this in interview or code assessment, and you're out the door. This vid misses the point entirely: not only does it skirt pointer manipulation (which is the essence of the question), it also avoids doing any direct comparisons by relying on the library _sorted_ routine. Additionally, creation of a separate list and linked list wastes both time and memory. ;(

keithmiklas
Автор

This is the biggest scam I have ever had the displeasure to witness. Seriously, he's so cheeky that it makes me laugh xD

nahuelmoreno
Автор

Hi, great video, may i get the full code for your node class and linked list class?

dragonpig