Important Note: Similar to the previous Linked List videos, for the deletion methods, since the method is returning a reference, you should update toDelete's reference such that it's no longer pointing to the list, that way you will not be able to reach the list by manipulating toDelete.
@evelynsummer40203 жыл бұрын
I don't get it can you explain
@BlueTreeCode3 жыл бұрын
@@evelynsummer4020 Hi Evelyn, at 8:55 for example, toDelete.next is still pointing to the node with value 14. This means that you still have access to the rest of the list if you assign the returned toDelete reference to another variable. You should only have access to the node itself, meaning that node's next should not point to another node when you return. To fix this, it's as easy as adding the following line before "return toDelete": toDelete.next = null; Hope this helps :)
@BlueTreeCode5 жыл бұрын
Hey Everyone! Thanks for checking out my video! Don't forget to Like, Subscribe, and MOST IMPORTANTLY click that Notification Bell for updates! :)
@kyledecena49593 жыл бұрын
thank you so much, so easy explanation. It helped me a lot.
@BlueTreeCode3 жыл бұрын
I'm glad it helped, Kyle! :) Feel free to share these videos with your friends as it would really help out the channel.
@johnpaulbancayrin61953 жыл бұрын
Dont stop uploaading about data structure and algorithm bro this is help me a lpt
@BlueTreeCode8 ай бұрын
Glad it was able to help!! Please don't forget to like and share as it will help the channel to grow.
@janaal-sokhon24624 жыл бұрын
great video. but would really appreciate it if you slowed down while talking as I had to replay some parts of the video to actually catch up with what you were saying. Good luck with the other videos!
@BlueTreeCode4 жыл бұрын
Thank you for the feedback, Jana Al-Sokhon :). I realized I began to speed up as I posted more videos, so I will be sure to take that into consideration in future videos. Glad you found the video helpful :)
@shivakumarkabballi4 жыл бұрын
awesome explanation Bro, Do more
@BlueTreeCode3 жыл бұрын
Thank you for the kind comment, Shiva!
@Rohit-jk5zi4 жыл бұрын
nice explanation..really was stuck with circular linked list
@BlueTreeCode4 жыл бұрын
I'm glad it helped, Rohit!
@mahbubulhaque31373 жыл бұрын
It's really Nice explanation
@BlueTreeCode3 жыл бұрын
Thank you, Mahbubul!
@amblypygi66512 жыл бұрын
I'm kinda a newbie but I think in the addAfter method you forgot the case in which we add a node after the last node. It might be a wrong take, but how I interpret it is that in this case the newly created node should become the new last node. So inside the if we should add that if curr==last then last=n.
@BlueTreeCode2 жыл бұрын
Hi @Ambypygi, Yup, that's correct. Adding the check inside the conditional as you mentioned will take that into consideration.
@money12343595 жыл бұрын
yoh fire outro, nice touch. I couldn't find the subscribe button though.
@BlueTreeCode5 жыл бұрын
Thanks man!
@kaitokid61762 жыл бұрын
Does the last Node have a Pointer to the first Node as its prev?
@ahmetkarakartal95633 жыл бұрын
thank you so much
@BlueTreeCode3 жыл бұрын
Thank you, Ahmet!
@Ajaysharma-ri9xi4 жыл бұрын
thanks a lot sir, I have a doubt suppose we have two pointers maintained one head and another tail then time complexity to insert at beg,end,after element will be??
@BlueTreeCode4 жыл бұрын
Hi Ajay sharma. Thanks for watching! It won't make any difference in regards to the time complexity with 2 references. You can set head to last.next if you wish, however, it's not necessary because to get the head, we simply retrieve last.next. If you do decide to add a head reference you will be using some more more memory (8 bytes) to store that reference. Hope this helps :)
@Ajaysharma-ri9xi4 жыл бұрын
@@BlueTreeCode thanks a lot sir u have replied to me, thanks for care. I got your point
@AishaStitt3 жыл бұрын
As an absolute beginner, i found this rather hard to comprehend at time 2:13 [last.next does not point to n.next| it still pointing to itself(visual) ]. and n.next looks as if it is pointing to 3. Yet when I am reading the code: I read it as last.next is being assigned to n.next; The visual is confusing how I am interpreting the code. Im sorry.
@BlueTreeCode3 жыл бұрын
Hi Aisha, thanks for the feedback! Don't be sorry! Circular Linked Lists tend to be tricky for beginners. Let's start with some quick definitions: At time 2:10 last = points to the node with value 3 last.next = points to the node with value 3 (this is because last and last.next both represent the same node) n = points to the node with value 5 n.next = points to Null At 2:13 , the code says, n.next = last.next, so what's happening here is that n.next which was originally pointing to null (before the point 2:13) is now pointing to the same node as last.next (node with value 3) Let me know if this helps, but if you're still confused, feel free to let me know where you're stuck.
@AishaStitt3 жыл бұрын
@@BlueTreeCode YOU ARE A GENIUS!!! last = points to the node with value 3 last.next = points to the node with value 3 (this is because last and last.next both represent the same node) THIS PART IS What helped me understand. Also you said it in 1:47 because this is the only node in my list. I will just set my last.next to itself. It didn't click until now. This is the little piece I was missing. Thank you sooo much for reiterating!!!
@BlueTreeCode3 жыл бұрын
@@AishaStitt You're most welcome, Aisha! I'm glad it helped! :)
@G007-e9p4 жыл бұрын
why is the algoritm same for add node to end and add node to start
@BlueTreeCode4 жыл бұрын
Hi gurveer aulakh, they look very similar, but "addToStart" adds the Node after the last reference, whereas "addToEnd" will add the Node after the last reference, but then have last reference it. Hope this helps :) NB: last.next is considered the first Node in the list.
@volkanulker74054 жыл бұрын
in addToStart part n.next=n should be last.next=n am i wrong about that ?
@BlueTreeCode4 жыл бұрын
Hi, Volkan. So, let's go through it. In addToStart, if last == null, then that means there are no nodes in the CLL. Now, if there are no nodes in the CLL, we want n to reference itself to form that circular structure, hence n.next = n, and then we have last reference n. If we said last.next = n, then we will get a NullPointerException, since last is null and therefore wouldn't have a next. Hope this helps :)
@volkanulker74054 жыл бұрын
@@BlueTreeCode got it thx
@harmansandhu37354 жыл бұрын
Yo
@themonster4759 Жыл бұрын
please just 1 qustion: AddToEnd(20); AddToEnd(10); AddToEnd(12); 12-> 20-> 10-> 12-> 20-> 10-> 12-> 20-> 10-> 12-> etc.. should the list start with 20 why there's 12 at the first