Argh, good catch @Johann Chu! I meant to flip 23 and 19 from the previous example. Thank you for pointing this out. The process is still the same, but the keys should be switched. 23 is the parent, and 19 is the left child.
I remember, I had watched the RB tree till insertion when I was at college and was just revising this topic. As the insertion example video ended, I thought it's the end. "But here we go again". Thanks 😂😂
Hi Michael thank you for the efforts and coming back to complete it after 5 years👍👍I watched all of them and they are very friendly to beginner like me👍
@@MichaelSambol Yeah i saw it, was wondering cause i had an issue with that, and didn't know if ive messed up in the implementation of the tree, or in the sutff around the tree. (I'm implementing a red black tree to recode std::map in c++ for a school project) And i had a recurrent segfaulft down the line in that particular case when both children are NIL : - by passing a NIL in transplant, prog crashes when calling the parent. Anyway if you are interested i've found a way to handle that on geeksforgeeks "fixDoubleBlack" Thx for the answer btw, i sub for that :)
Thanks for the video! Just a thought - for if none of the children is nil, isn't it easier to exchange the value of the node to be deleted and the minimal of its right subtree, then delete the node that was exchanged? Instead of doing all the pointer manipulation.
You are excellent man.. thanks for these short yet high-value clips... Red-black trees are now clear for me. By any chance you have similar clips for 2-3-4 trees?
Thanks for the explanation. For the transplant function, since you'd like to check whether the 2 variables `u.p.left` and `u` point to the same object, not the value in the object, would it be more appropriate to use `is` syntax than `==` ?
I checked your code and there is a line which I don't quite understand. It's about line 155-156: if y.p == z: x.p = y. If I understand it correctly there is no point in setting x.p = y since y is already x's parent. Can you explain it to me? Thanks
@@zuzannabozek1238 wyszło na to, że to było w celu spójności drzewa, w tym specyficznym przypadku nie jest potrzebna, bo wszystko jest napisane poprawnie. ale jak zmienisz logikę funkcji transplant i się okaże, że ta logika jest niepoprawna to ta linijka to wychwyci, takie zabezpieczenie. ale nie pytaj mnie o więcej bo to było dwa lata temu i ja już tego algorytmu do końca nie pamiętam. xD
3:49, is the 23 misplaced? (Should be the right child of 19?)
Argh, good catch @Johann Chu! I meant to flip 23 and 19 from the previous example. Thank you for pointing this out. The process is still the same, but the keys should be switched. 23 is the parent, and 19 is the left child.
@@MichaelSambol Got it. Thanks for making these clips man, they are really crystal clear. Thumbs up!
You're welcome! Thanks for the comment. I do my best and i have external review but sometimes I miss, so I appreciate it!
i was yelling over chathpt and telling him he is making a misstake poor chatgpt lol
I've been waiting for 5 years to pass the course thx for the video
😂
Bro i just started this playlist today and the fact you took 5 years off 😂😂😂😂 hope you're all good i just find that hilarious. better late than never.
Pathetic, right?! I got lazy. But I'm back!
I’ve waited 5 years just for your video 😂
😂🫱🏼🫲🏽
Procrastination pays off, I can watch the whole red-black playlist all at once now :D
5 years late? you're just on time for me! thanks for the video
Love it! Welcome.
thank you so much for continuing the red black tree series ^^ its much of help to me :D clear, concise and understandable!
you're welcome!
Just watched the 4 previous video and at the same day 5th video is uploaded 👍
same
perfect timing! one more coming (hopefully tonight).
🇺🇦
@@hlibdolinin4404 Same for me. Доречі не очікував тут украхнців побачити
@@kskbekfoznwd курсова робота не шкодує нікого)
i rearly comment in any type of video but i must say you did a really good job, thanks for your work to help us understand more about programming
I remember, I had watched the RB tree till insertion when I was at college and was just revising this topic.
As the insertion example video ended, I thought it's the end. "But here we go again". Thanks 😂😂
I've been waiting for this
Я ждал ето 20 секунд пока реклама шла
I'm so lucky that you released this now right when i need it
Hi Michael thank you for the efforts and coming back to complete it after 5 years👍👍I watched all of them and they are very friendly to beginner like me👍
Hi micheal, yes, better late then never, I was watching this series today, and this video will continue to help me pass my class lol
right when we needed him most, he reappeared
thankfully I am watching this 7 years late
just in time
bro casually waited 5 years to continue his masterpiece thank god I started learning red black trees after he finished this playlist
Just in time 🤪
😂😂😂😂@@MichaelSambol
dude how tf is this channel not discovered by people yet
slow and steady... thanks for watching!
damn bro literally returned after 5 year
Back!
Bro your explanations are top notchh
thanks bro! yours too.
Perfect timing man, I have an exam in 3 days :D
The sequel we needed
4:36 Just wondering, why don't we consider if both children are NIL ?
if node is black it breaks the tree balance.
If both children are nil, the first case is true. :)
github.com/msambol/youtube/blob/master/trees/red_black_tree.py#L142
@@MichaelSambol
Yeah i saw it, was wondering cause i had an issue with that, and didn't know if ive messed up in the implementation of the tree, or in the sutff around the tree.
(I'm implementing a red black tree to recode std::map in c++ for a school project)
And i had a recurrent segfaulft down the line in that particular case when both children are NIL :
- by passing a NIL in transplant, prog crashes when calling the parent.
Anyway if you are interested i've found a way to handle that on geeksforgeeks "fixDoubleBlack"
Thx for the answer btw, i sub for that :)
Previous video: "Today you'll see examples of red-black tree insertion! 😃😁"
This one: "Better late than never. Even if I am 5 years late 🧔 👴"
🤦🏻♂️
🤦🏻♂️
Thanks for the video! Just a thought - for if none of the children is nil, isn't it easier to exchange the value of the node to be deleted and the minimal of its right subtree, then delete the node that was exchanged? Instead of doing all the pointer manipulation.
this is so funny T-T I'm shocked with your voice changing
Why did you consider NiL to be red in the end???
You are excellent man.. thanks for these short yet high-value clips... Red-black trees are now clear for me. By any chance you have similar clips for 2-3-4 trees?
Thank you! I haven't done 2-3-4 trees yet but they're on the list.
Since nil is a black node in the last example, is there not an equal number of black nodes across each path?
Yes, It has to be
DSA God ! Thank you so much :)
Thanks for the explanation. For the transplant function, since you'd like to check whether the 2 variables `u.p.left` and `u` point to the same object, not the value in the object, would it be more appropriate to use `is` syntax than `==` ?
I'm watching the playlist and the voice change hit me like a truck 😂
did it get deeper? higher T I guess
6:48 You call tansplant and the second argument is null. But this is not covered in by the method's code on 1:35
It is not null, it is NIL node, which is still a node with a parent.
how can i call fixup for deleted node???
github.com/msambol/dsa/blob/master/trees/red_black_tree.py :)
Nice work man thanks
I'm coming for the delete-mixup haha
what about the case that both children are nill?
this case? github.com/msambol/dsa/blob/master/trees/red_black_tree.py#L182
Thanks this helped a lot
I checked your code and there is a line which I don't quite understand. It's about line 155-156: if y.p == z: x.p = y. If I understand it correctly there is no point in setting x.p = y since y is already x's parent. Can you explain it to me? Thanks
It is, but you need to set the pointer :)
@@MichaelSambol oh okay, I'll read more about it, thank you for your answer :)
@ksaweryhasnik do you have an answer? It seems like that pointer should be correct already...
@@zuzannabozek1238 wyszło na to, że to było w celu spójności drzewa, w tym specyficznym przypadku nie jest potrzebna, bo wszystko jest napisane poprawnie. ale jak zmienisz logikę funkcji transplant i się okaże, że ta logika jest niepoprawna to ta linijka to wychwyci, takie zabezpieczenie.
ale nie pytaj mnie o więcej bo to było dwa lata temu i ja już tego algorytmu do końca nie pamiętam. xD
@@ksaweryhasnik dzięki ❤️
When l created red black tree why i delete node what the fuck 😂😂😂