Amazing videos. The best service in the world is to share your knowledge with others and you're doing it well. Thank you very much. So, the prepend is exactly like append except you set the self.head to the new node. I felt that it would be better to not repeat the same code at multiple places. The below should work fine too. def append(self, data): if self.head is None: new_node = Node(data) self.head = new_node self.head.next = self.head else: new_node = Node(data) cur = self.head while cur.next != self.head: cur = cur.next cur.next = new_node new_node.next = self.head return new_node def prepend(self, data): new_node = self.append(data) self.head = new_node
A great goal :). Cheers, and thanks for watching! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my TH-cam page. bit.ly/lp_email
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my TH-cam page. bit.ly/lp_email
Please continue your good work... Amazing channel.. You do every step by coding not only lecturing... that's why this channel is very good.. I would like to suggest you to do some database topics too.. good luck... good channel.. your channel is underrated, you deserve 1 million subs. definitely One day you can achieve that... !!!!
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing! I really appreciate the support, and if you want to support the channel, I do have a PayPal link paypal.me/VincentRusso1 for donations that go directly to the creation of content on this channel. I hope that the content I provide there will enhance the videos on my TH-cam page. bit.ly/lp_email
Hi.... I am from India... I really like your videos and I a watch them frequently. They are just great. Please upload videos on exponential tree data structure also in your data structure series.
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
Hi Lucid , I have paid for some course(s) in udemy to get depth knowledge on datastructure and algorithm in Python . But i was eventually end up with confusions in the mid of course(s) and thought of negative thinking like i can't learn data structures and alogorithm anymore . Later i got notification for your videos on youtube and i really loved the way you explain each and every topic(s) . Actually your teaching method is pretty awesome and it gave me confidence in programming . Let me come to the point here . I have managed to create prepend function in circular linked list and this also works . Kindly validate and let me know if i am missing anything here . Thank you very much all you do for the students like me ( beginner and intermediate ) . def prepend(self,data): new_node = Node(data) p = self.head q = self.head if not self.head: new_node.next = new_node self.head = new_node while p.next != self.head: p = p.next
Hi Murali. That's great to hear. In fact, I would recommend staying away from Udemy. They tend to steal and misattribute content from creators. If you would like more of a course form for the type of work I did, I worked with Educative to put together a data structures and algorithms course: www.educative.io/courses/ds-and-algorithms-in-python Regarding your code, I took a quick look and don't see anything terribly wrong with it. Hope that helps!
Hi Lucid, it seems to me that we can reuse the same code of append for prepend except that we move the head to the new node at the end in prepend(), correct?
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
In the prepend step, why didn't we make the new_node to point the self.head before making the new node into the self head? Like, cur.nex=new_node new_node.next= self.head self.head=new_node
To maintain O(1) for prepending, I initialise with a "tail_node" variable that stores the address of the original head of the list. By doing so, each time I push a new node - which becomes the new head- that "tail_node" will point to the new node. Thus, the list does not require traversal
@@deni9264 Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
Why would we make a prepend and append with a circular linked list? The fact that it's only a singly linked list means that iterating from the tail will actually make it go through one more iteration then it has to, no?
LucidProgramming firstly, thanks for answering! Secondly, I believe your implementation is singly linked. At 1:23 and 1:45 you mention that the classes are identical to singly linked list, in other words, a ‘previous’ reference was never made, meaning it can only iterate forward. Even so, is there a difference between prepend and append in a doubly linked circular list? It would only shift the head by 1, but, since its doubly linked, we can get to either node next to the head with .next or .previous.
@@Momo-bb2fn But a circular linked list is not a singly linked list. If you look at the classes I have in both videos for both separate topics, you'll see that their core implementation is different as they are different objects.
Heyyy thanks for all these videos but can you tell which programming language is best for implementation and efficiency of pointers as there is no term as pointers in python and what would be better to learn for placement exams from the university.
I can’t even begin to explain how this video meant to me. But I have a little problem in 4:23: self.head.next =self.head why we need to point self.head to itself in circular linked list
Why do prepend in O(n) by creating a new node in front of self.head? instead you can create the new node between self.head and self.head.next and then simply swap the data. This allows the operation to be done in O(1) because the 'tail' node's .next does not need to be swapped
Hello sir please bring a video on merging of two circular linked lists in python I really need your help . I need this for my project in next 2 days I have to submit
def prepend(self,data): newnode=Node(data) if not self.head: self.head=newnode self.head.next=self.head else: newnode.next=self.head self.head=newnode why it is going to infinite loop??
There's a bug in your code. you need to return here def append(self, data): if not self.head: self.head = Node(data) self.head.next = self.head return otherwise, it'll be stuck in infinite loop
@@tejaskhandare9270 Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
Hi Malik. Sorry to hear it was too fast. Indeed, I will try to factor this into future videos. You can always try to use TH-cam's built-in feature to slow down the playback speed. Hope that helps, cheers!
No problem, Malik. Trust me, I've been there plenty of times! I hope my other videos can help with your current homework, and feel free to reach out to my email in the "About" section if you're still struggling. I do offer tutoring via Google Hangouts, and we discuss that if you think that would be helpful to you. In any case, thanks for your comment, and I still do appreciate the feedback, positive or negative. I'm all about trying to make the content better, so it's helpful in any case. Cheers.
Very didatic, clear and essential; You are at least 1000 x better than my data structutre teachers all added together. Keep up the excelent work
the quality of these videos is really good man . you deserve more views.
Thank you, Ravi. I appreciate your comment, and here's hoping other viewers have the same outlook as you. Cheers!
Very nice explanation sir
Cheers, thank you for watching!
If I can sound as calm as you do while talking about code, I'll know I've made it in life.
Thank you for the content!!
Thanks for the kind words. Cheers!
Amazing videos. The best service in the world is to share your knowledge with others and you're doing it well. Thank you very much. So, the prepend is exactly like append except you set the self.head to the new node. I felt that it would be better to not repeat the same code at multiple places. The below should work fine too.
def append(self, data):
if self.head is None:
new_node = Node(data)
self.head = new_node
self.head.next = self.head
else:
new_node = Node(data)
cur = self.head
while cur.next != self.head:
cur = cur.next
cur.next = new_node
new_node.next = self.head
return new_node
def prepend(self, data):
new_node = self.append(data)
self.head = new_node
But the data is added to the end of the list, not the beginning, so your prepend function isn't correct.
@@LucidProgramming ah Thank you!
Amazing series! My goal is to realize all your materials about programming in Python. Thank You!
A great goal :). Cheers, and thanks for watching!
If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
I hope that the content I provide there will enhance the videos on my TH-cam page.
bit.ly/lp_email
the student will never become the master hahaha
Thank you LucidProgramming for these insightful content. Please make more video on DSA and more algorithm
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
@@LucidProgramming I already did, even I refer your content with my junior and colleagues.
@@rahulmaurya597 That is awesome, I sincerely appreciate all of that support. Thank you!
Nice video, I was struggling to understand circular linked list just by looking at the code, your video helped me understand the code part. Thanks!
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
I really appreciate the support, and if you want to support the channel, I do have a PayPal link (www.paypal.me/VincentRusso1) for donations that go directly to the creation of content on this channel.
I hope that the content I provide there will enhance the videos on my TH-cam page.
bit.ly/lp_email
Please continue your good work... Amazing channel.. You do every step by coding not only lecturing... that's why this channel is very good.. I would like to suggest you to do some database topics too.. good luck... good channel.. your channel is underrated, you deserve 1 million subs. definitely One day you can achieve that... !!!!
Thank you! If you like my content, I've been working on some projects during the past couple of months. If you would like to stay up-to-date, please consider subscribing to my mail list. Also, if you haven't already, please consider subscribing!
I really appreciate the support, and if you want to support the channel, I do have a PayPal link
paypal.me/VincentRusso1
for donations that go directly to the creation of content on this channel.
I hope that the content I provide there will enhance the videos on my TH-cam page.
bit.ly/lp_email
Hi.... I am from India... I really like your videos and I a watch them frequently. They are just great. Please upload videos on exponential tree data structure also in your data structure series.
It's on my list, just need to find the time to record them!
Very Informative man. Keep going..!!
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
nicely explained thanks for the clear explanation.
Hi Lucid , I have paid for some course(s) in udemy to get depth knowledge on datastructure and algorithm in Python . But i was eventually end up with confusions in the mid of course(s) and thought of negative thinking like i can't learn data structures and alogorithm anymore . Later i got notification for your videos on youtube and i really loved the way you explain each and every topic(s) . Actually your teaching method is pretty awesome and it gave me confidence in programming . Let me come to the point here . I have managed to create prepend function in circular linked list and this also works . Kindly validate and let me know if i am missing anything here . Thank you very much all you do for the students like me ( beginner and intermediate ) .
def prepend(self,data):
new_node = Node(data)
p = self.head
q = self.head
if not self.head:
new_node.next = new_node
self.head = new_node
while p.next != self.head:
p = p.next
new_node.next = q
self.head = new_node
p.next = new_node
Hi Murali. That's great to hear. In fact, I would recommend staying away from Udemy. They tend to steal and misattribute content from creators. If you would like more of a course form for the type of work I did, I worked with Educative to put together a data structures and algorithms course:
www.educative.io/courses/ds-and-algorithms-in-python
Regarding your code, I took a quick look and don't see anything terribly wrong with it. Hope that helps!
@@LucidProgramming Thank you Lucid 😊♥️
@@muraliperi7669 Of course!
Hi Lucid, it seems to me that we can reuse the same code of append for prepend except that we move the head to the new node at the end in prepend(), correct?
That's the general idea, yes.
Very nice tutorial. Thank you very much!
Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
In the prepend step, why didn't we make the new_node to point the self.head before making the new node into the self head? Like,
cur.nex=new_node
new_node.next= self.head
self.head=new_node
Excellent video 10/10
Thanks, Ray J!
To maintain O(1) for prepending, I initialise with a "tail_node" variable that stores the address of the original head of the list. By doing so, each time I push a new node - which becomes the new head- that "tail_node" will point to the new node. Thus, the list does not require traversal
Nice. You lose a little on space but gain in time. Thanks for sharing!
@@LucidProgramming Thanks. Yeah i think the trade-off is worth it for a large lists. I have also learnt alot from your videos
@@deni9264 Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
How is Node class accessed if it is written outside of the Circular Linked list class? Please explain.
Because it's still in the same file.
during the execution of WHILE loop I am getting an error 'NoneType' object has no attribute 'ref'
Did you check the code on my GitHub?
Why would we make a prepend and append with a circular linked list? The fact that it's only a singly linked list means that iterating from the tail will actually make it go through one more iteration then it has to, no?
Your first statement contradicts your second. A circular linked list is not a singly linked list.
LucidProgramming firstly, thanks for answering! Secondly, I believe your implementation is singly linked. At 1:23 and 1:45 you mention that the classes are identical to singly linked list, in other words, a ‘previous’ reference was never made, meaning it can only iterate forward. Even so, is there a difference between prepend and append in a doubly linked circular list? It would only shift the head by 1, but, since its doubly linked, we can get to either node next to the head with .next or .previous.
@@Momo-bb2fn But a circular linked list is not a singly linked list. If you look at the classes I have in both videos for both separate topics, you'll see that their core implementation is different as they are different objects.
Heyyy thanks for all these videos but can you tell which programming language is best for implementation and efficiency of pointers as there is no term as pointers in python and what would be better to learn for placement exams from the university.
Python has pointers.
@@LucidProgramming realpython.com/pointers-in-python/ I referred this can you please elaborate
This was really helpful. Could you please add a delete function video?. Thanks
I do take requests on my patreon page, so if there is a topic or video you would like to see made, be sure to put in a request. Thanks again!
I can’t even begin to explain how this video meant to me.
But I have a little problem in 4:23:
self.head.next =self.head
why we need to point self.head to itself in circular linked list
Because that's the way in which we define the data structure. The head must point to the tail to give it the "circular" structure.
Why do prepend in O(n) by creating a new node in front of self.head? instead you can create the new node between self.head and self.head.next and then simply swap the data. This allows the operation to be done in O(1) because the 'tail' node's .next does not need to be swapped
Hello sir please bring a video on merging of two circular linked lists in python I really need your help . I need this for my project in next 2 days I have to submit
what is the different of append in linked list and circular linked list?
They both add an element to the end of the list.
nice vim skills :)
Haha, thanks! :)
getting attribute error at -------> while cur.next != self.head
def prepend(self,data):
newnode=Node(data)
if not self.head:
self.head=newnode
self.head.next=self.head
else:
newnode.next=self.head
self.head=newnode
why it is going to infinite loop??
Did you make sure you code matches mine?
While cur.next!= self.head:
Error: Nontype object has no attribute 'next'
Did you check the GitHub account to compare your code against mine?
did you fix this error yet ?
@@Worldnme Did you do what I suggested in the above comment?
if we add "self.head=new_node" in append function we will get code for prepend:)
Is that true? I"m not sure that's quite right.
There's a bug in your code.
you need to return here
def append(self, data):
if not self.head:
self.head = Node(data)
self.head.next = self.head
return
otherwise, it'll be stuck in infinite loop
(self.data = data_) Why this _ is used
Anyone?
That is just vim being vim. There's no character actually there.
@@LucidProgramming Thanks sir!
Much appreciate ur efforts n support
@@tejaskhandare9270 Cheers! If you enjoyed and benefited from my content, please consider liking the video and subscribing to the channel for more content like this. If you would like to support the content creation on this channel please consider unblocking ads when watching my videos as this is how I support my time to make content. I hope to be putting out more similar videos soon!
TOO FAST
Hi Malik. Sorry to hear it was too fast. Indeed, I will try to factor this into future videos. You can always try to use TH-cam's built-in feature to slow down the playback speed. Hope that helps, cheers!
Thanks for the reply, and sorry for the use of caps (late night homework can be mentally taxing). Looking forward to future videos.
No problem, Malik. Trust me, I've been there plenty of times! I hope my other videos can help with your current homework, and feel free to reach out to my email in the "About" section if you're still struggling. I do offer tutoring via Google Hangouts, and we discuss that if you think that would be helpful to you. In any case, thanks for your comment, and I still do appreciate the feedback, positive or negative. I'm all about trying to make the content better, so it's helpful in any case. Cheers.