Data Structures in Python: Singly Linked Lists -- Insertion

preview_player
Показать описание
This video is sponsored by Oxylabs. Oxylabs provides market-leading web scraping solutions for large-scale public data gathering. You can receive data in JSON or CSV format and pay only per successful request. At the moment, Oxylabs offers a free trial.

In this video, we very briefly introduce the notion of the "linked list", specifically the "singly linked list" data structure. It is assumed that the viewer is somewhat familiar with this concept and has been exposed to it at some earlier level, for instance in the context of a computer science course, etc.

We review the basic trade-offs of linked lists versus arrays, and then we proceed to describe and program how one may insert data into a linked list. We investigate three different insertion methods:

- Append (add element to end of list)
- Prepend (add element to beginning of list)
- Add element after element in the list.

We proceed to implement these methods in Python.

The software written in this video is available at:

Slides:

Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:

If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
Рекомендации по теме
Комментарии
Автор

You absolutely crush my CS profs. They can't teach their way out of a wet paper bag. Your walkthrough and code examples are great.

kamaboko
Автор

Thank you so much for the video:
For those who would like to send a string as a node in the insert_after_node function :
def insert_after_node(self, prev_node, data):
new_node = Node(data)
cur_node = self.head
while(cur_node.data != prev_node):
cur_node = cur_node.next
if(cur_node is None):
print("previous node is not present in the list")
return
new_node.next = cur_node.next
cur_node.next = new_node

Foxdon
Автор

by far the best video and trust me, I TRIED WATCHING 20 DIFFERENT VIDS

sakshamdogra
Автор

This is the best tutorial about linkedlists I've come across so far. Really well explained, thank you for your great work.

Magmatic
Автор

Thanks for the video.The explanation is clear
For those who like to insert a node at a particular position:
def insert_at_position(self, pos, data):
current_node = self.head
for i in range(pos-1):
if(current_node.next):
current_node = current_node.next
i = i+1
if i != pos-1:
print('unable to insert')
else:
new_node = Node(value)
new_node.next = current_node.next
current_node.next = new_node

roshanmadipalli
Автор

This playlist is GOLD !! Thanks a lot Lucid Programming

shreya_sinha.
Автор

Finally found a tutorial for my specific use case. A lot of other tutorials used indexes/predefined stuff, I only had the list items to go on. This worked like a charm. You saved me!

bommes
Автор

Thank you very much for the video explanation, you don't just show the code like other bloggers, you will explain with pictures, and! You will often return to the image to parse the code, as a newbie, I love you

jiajingxie
Автор

Best DSA Cours on Youtube RN !
Thank you so much !

ghcrocket
Автор

So well explained it's unreal. Cheers man thank you for giving us self taught programmers quiality resources for no cost at all!

xaralabosful
Автор

Coding this alongside with you was very much fun. And moreover, code along with linked list explanation is what I have not found elsewhere..Thank you for your time

arjunreddy
Автор

i am actually attending bootcamp but did not understand this concept and now got it cleared after watching ur video, thanks a lot!

gauravpatil
Автор

After watching several videos about Linked List, it seems that this is the best video. One may say that this is not apple to apple as I watched this video after learning it from the others first but it is not actually as this video is indeed the best for understanding the Linked List. Thanks Lucid Prog. really appreciate it. God bless.

hendrag
Автор

the best programming channel on YouTube hands down. clear, thorough, no rush. best wishes

mulhamjarjanazi
Автор

thank you so much dude, literally from 3 days i was scratching my head that how does linked list work

surathjhakal
Автор

who needs a CS degree when you have Vincent! Thanks LucidProgramming :) just subbed

qc
Автор

THIS. IS. AMAZING. I'm a freshman and my college is explaining DS on C programming for my 1st semester with exact terminologies like head and last_node. You made the exact same with python syntax and way easier explanation than my professor. Thank you

nikhilb
Автор

This is definitely the best video I've seen on Linked Lists, keep up the amazing work and thanks a lot!

davidtorres
Автор

sir how can i say thanks to you i have no words to express my feelings how happy i am i tried udemy and many other paid courses but they make things complex but your tutorial helps me a lot after watching your video on link list it's look more easier then to learn printing hello world from any other youtube tutorial !! thanks to a legend :-)

sahilbisht
Автор

Actually this makes me clear about the topic
its simply Great !!!
with easier Explanation
Especially with the figures drawn..
Well Done :)
I like

vijayanandv