Circular Linked List | Insert, Delete, Complexity Analysis

  Рет қаралды 17,668

Blue Tree Code

Blue Tree Code

Күн бұрын

Пікірлер: 37
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
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.
@evelynsummer4020
@evelynsummer4020 3 жыл бұрын
I don't get it can you explain
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
@@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 :)
@BlueTreeCode
@BlueTreeCode 5 жыл бұрын
Hey Everyone! Thanks for checking out my video! Don't forget to Like, Subscribe, and MOST IMPORTANTLY click that Notification Bell for updates! :)
@kyledecena4959
@kyledecena4959 3 жыл бұрын
thank you so much, so easy explanation. It helped me a lot.
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
I'm glad it helped, Kyle! :) Feel free to share these videos with your friends as it would really help out the channel.
@johnpaulbancayrin6195
@johnpaulbancayrin6195 3 жыл бұрын
Dont stop uploaading about data structure and algorithm bro this is help me a lpt
@BlueTreeCode
@BlueTreeCode 8 ай бұрын
Glad it was able to help!! Please don't forget to like and share as it will help the channel to grow.
@janaal-sokhon2462
@janaal-sokhon2462 4 жыл бұрын
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!
@BlueTreeCode
@BlueTreeCode 4 жыл бұрын
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 :)
@shivakumarkabballi
@shivakumarkabballi 4 жыл бұрын
awesome explanation Bro, Do more
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
Thank you for the kind comment, Shiva!
@Rohit-jk5zi
@Rohit-jk5zi 4 жыл бұрын
nice explanation..really was stuck with circular linked list
@BlueTreeCode
@BlueTreeCode 4 жыл бұрын
I'm glad it helped, Rohit!
@mahbubulhaque3137
@mahbubulhaque3137 3 жыл бұрын
It's really Nice explanation
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
Thank you, Mahbubul!
@amblypygi6651
@amblypygi6651 2 жыл бұрын
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.
@BlueTreeCode
@BlueTreeCode 2 жыл бұрын
Hi @Ambypygi, Yup, that's correct. Adding the check inside the conditional as you mentioned will take that into consideration.
@money1234359
@money1234359 5 жыл бұрын
yoh fire outro, nice touch. I couldn't find the subscribe button though.
@BlueTreeCode
@BlueTreeCode 5 жыл бұрын
Thanks man!
@kaitokid6176
@kaitokid6176 2 жыл бұрын
Does the last Node have a Pointer to the first Node as its prev?
@ahmetkarakartal9563
@ahmetkarakartal9563 3 жыл бұрын
thank you so much
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
Thank you, Ahmet!
@Ajaysharma-ri9xi
@Ajaysharma-ri9xi 4 жыл бұрын
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??
@BlueTreeCode
@BlueTreeCode 4 жыл бұрын
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-ri9xi
@Ajaysharma-ri9xi 4 жыл бұрын
@@BlueTreeCode thanks a lot sir u have replied to me, thanks for care. I got your point
@AishaStitt
@AishaStitt 3 жыл бұрын
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.
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
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.
@AishaStitt
@AishaStitt 3 жыл бұрын
@@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!!!
@BlueTreeCode
@BlueTreeCode 3 жыл бұрын
@@AishaStitt You're most welcome, Aisha! I'm glad it helped! :)
@G007-e9p
@G007-e9p 4 жыл бұрын
why is the algoritm same for add node to end and add node to start
@BlueTreeCode
@BlueTreeCode 4 жыл бұрын
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.
@volkanulker7405
@volkanulker7405 4 жыл бұрын
in addToStart part n.next=n should be last.next=n am i wrong about that ?
@BlueTreeCode
@BlueTreeCode 4 жыл бұрын
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 :)
@volkanulker7405
@volkanulker7405 4 жыл бұрын
@@BlueTreeCode got it thx
@harmansandhu3735
@harmansandhu3735 4 жыл бұрын
Yo
@themonster4759
@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
Stack Implementation - Array
9:55
Blue Tree Code
Рет қаралды 4,4 М.
Singly Linked List | Insert, Delete, Complexity Analysis
14:39
Blue Tree Code
Рет қаралды 62 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 16 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
Data Structures in Python: Circular Linked Lists -- Append and Prepend
13:27
Doubly Linked List | Insert, Delete, Complexity Analysis
17:17
Blue Tree Code
Рет қаралды 69 М.
Circular Linked List in Data Structures (with Code)
21:46
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 52 М.
Binary Heap - Insert, Sift Up, Delete, Sift Down, Heapify(BuildHeap)
23:06
Introduction to Linked Lists (Data Structures & Algorithms #5)
18:47
Circular Linked List Tutorial - Why Use a Circular List?
11:19
Tech With Tim
Рет қаралды 20 М.
Removing a node from doubly linked lists
11:18
CodeVault
Рет қаралды 7 М.
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 350 М.
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 518 М.
LinkedList 13 Circular Linked Lists
7:34
RobEdwards
Рет қаралды 24 М.
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН