Red-black trees in 4 minutes - Intro

  Рет қаралды 730,951

Michael Sambol

Michael Sambol

Күн бұрын

Пікірлер: 181
@arpitchristy9788
@arpitchristy9788 3 жыл бұрын
I still remember in past, I had to go through a long list to find his video. Now, when I searched it, it came on top! :D
@ThomasEdits
@ThomasEdits 7 ай бұрын
if only you could go through a red black tree instead
@dennisekiller
@dennisekiller 7 ай бұрын
@@ThomasEdits GO SLEEP, UNI TOMORROW
@DarkDay2012
@DarkDay2012 3 жыл бұрын
Studying for a Data Structures Final and your videos are really about to save me. Thanks man
@EskyDinpuiaChhangte
@EskyDinpuiaChhangte 5 жыл бұрын
A red-black tree is a binary tree that satisfies the following red-black properties: 1. Every node is either red or black. 2. The root is black. 3. Every leaf (NIL) is black. 4. If a node is red, then both its children are black. 5. For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.
@letsgoo4663
@letsgoo4663 Жыл бұрын
Y’all be qouting CLRS for real
@alanisromer9089
@alanisromer9089 11 ай бұрын
y u repeating the vid is 4 min long
@ante1337
@ante1337 6 жыл бұрын
Note: Leafs with value Null (aka NIL) are by default Black. This means a representation of a tree with a red "Leaf" can correctly be a Red-Black Tree since its children are Null, which are Black.
@ata500
@ata500 6 жыл бұрын
Thank you! This was so much easier to understand then my school textbook. You speak clearly and concisely. Great visuals and loved the short video time!
@sj1997
@sj1997 6 жыл бұрын
dude you just nailed it simple short precise and a clear explanation no trash talking respect from india man
@EskyDinpuiaChhangte
@EskyDinpuiaChhangte 5 жыл бұрын
A red-black tree is a binary search tree with one extra bit of storage per node: its color, which can be either RED or BLACK. By constraining the node colors on any simple path from the root to a leaf, red-black trees ensure that no such path is more than twice as long as any other, so that the tree is approximately balanced.
@letsgoo4663
@letsgoo4663 Жыл бұрын
Y’all be qouting CLRS for real
@Tourach74
@Tourach74 3 жыл бұрын
I am struggling for few hours ow to understand Red-black trees, and your videos are finally the ones that made it clear to me. Thanks and congrats! You won a new subscriber :)
@MichaJabczynski
@MichaJabczynski 8 жыл бұрын
Great videos, very clear and understandable. Keep up the good work!
@thomasjinton3862
@thomasjinton3862 Жыл бұрын
Totally agree :D
@Salamandolo
@Salamandolo 6 жыл бұрын
rut
@ryanbarry7670
@ryanbarry7670 5 жыл бұрын
really understandable tutorial? I agree!
@RaleighLittles
@RaleighLittles 4 жыл бұрын
1:57
@honglichen4670
@honglichen4670 5 жыл бұрын
I was confused that the Node 5 is black. However, when I watched the video again, It just said all red nodes have black nodes children, but not all black nodes have red children. So, the reason why Node 5 is black is to have the same black height. Right?
@firezdog
@firezdog 5 жыл бұрын
I'm not sure what you mean when you say they have a guaranteed height of O(log n) -- I thought O() is used to characterize performance -- and you could just say that the guaranteed height is < log n...
@matthewrenze5922
@matthewrenze5922 4 жыл бұрын
It is, but the definition of O(n) is more general than that. Most functions f(x) are equal to O(g(x)) for some g(x), and in a balanced binary search tree such as a red-black tree, height is a function of the number of nodes.
@ca4307
@ca4307 2 жыл бұрын
u say root funny, but thanks for the clear and concise explanation!
@muralikrishnaraju
@muralikrishnaraju 7 жыл бұрын
Aren't 9,13 and 23 leaf nodes.. Can I know why they are in red and not in black ? Please help me understand..
@MichaelSambol
@MichaelSambol 7 жыл бұрын
The leaf nodes are actually their NIL children.
@muralikrishnaraju
@muralikrishnaraju 7 жыл бұрын
Thanks for the answer. Isn't the same case for 5 as well? Can I know why 5 is seen as a leaf node when it is having NIL children?
@MichaelSambol
@MichaelSambol 7 жыл бұрын
5 isn't a leaf. Just because a node is black doesn't mean it's a leaf (see: 8, 12, 19).
@muralikrishnaraju
@muralikrishnaraju 7 жыл бұрын
Thank you
@jbob2015
@jbob2015 7 жыл бұрын
These videos are amazing keep up the good work and you'll make it big in no time
@yadhunandhanr7590
@yadhunandhanr7590 6 жыл бұрын
I love the way the video is made. Perfect!!
@NirajSingh-nv2jb
@NirajSingh-nv2jb 6 жыл бұрын
Best and simplest explanation on insertion of R-B tree on youtube. Please upload video on deletion.
@ethanraymosqueda3780
@ethanraymosqueda3780 7 жыл бұрын
when it says that all paths from a node to its NIL descendants contain the same number of black nodes, how many black nodes does node(9) have? Does it have 1? if so doesn't node(8) have 2 black nodes to NILL?
@billpetrak
@billpetrak 6 жыл бұрын
I wish you had also included deletions in your r-b trees series. Good explanations though.
@mrmansir3734
@mrmansir3734 11 ай бұрын
I know you mentioned that the RBTs are balanced, but it should also be one of the criteria at 1:15
@ThomasEdits
@ThomasEdits 7 ай бұрын
due to the criteria 3 + criteria 4, it must always be the case that it is roughly balanced since worst case longest path alternates black and red nodes while the shortest one has full black -> height ratio between the two children of a node can never be worse off than 1:2
@Cyber_Jutsu
@Cyber_Jutsu Жыл бұрын
excellent series!
@jackc451
@jackc451 3 жыл бұрын
Am I right in saying that the example is not a R-B Tree because it's not balanced? There is a difference in height of 2 between the left and right sub trees from the root. The video is like 5 years old now, but I just wanted to ask for my own clarity :)
@Kikiri197
@Kikiri197 Жыл бұрын
i don't know if it would be still helpfull, but R-B tree doesn't have to be AVL tree (the condition you have mentioned). R-B trees have different conditions for "being balanced"
@ryandavis7506
@ryandavis7506 7 жыл бұрын
Absolutely killing it, dude. Keep going and don't stop. Easy subscribe. Thx.
@regisschulze6678
@regisschulze6678 7 жыл бұрын
yeah man I feel ya even subscribed my grandma without her knowing
@Makwayne
@Makwayne 2 жыл бұрын
Me watching on 2x "red-black trees in 2 minutes"
@stephenhowe4107
@stephenhowe4107 4 жыл бұрын
Insert and Delete require rotations and recolorations, sometimes both.
@tecnaharmonix3416
@tecnaharmonix3416 3 жыл бұрын
Please make a video on deletion too
@mrmansir3734
@mrmansir3734 11 ай бұрын
but why do nodes turn red sometimes? wasnt explained it NVM seems you explain it in diff video. Thats just the algorithm, we insert each node as red but change it to black if we have to match the rules.
@Kevin-jf6jw
@Kevin-jf6jw 4 жыл бұрын
Wonderful one! Btw, where is the node-removing part? Thanks.
@drrpedpeppadsa
@drrpedpeppadsa 2 жыл бұрын
Good video. I wish you revisited the unbalanced example that is the reason for using a red-black tree (binary search tree with all children nodes being lesser).
@shivanshpradhan8860
@shivanshpradhan8860 7 жыл бұрын
very well explained in short time
@mohammadmohammadian6706
@mohammadmohammadian6706 Жыл бұрын
upload more man you are amazing
@thomasfischer9289
@thomasfischer9289 6 жыл бұрын
What about node 5? That node is black and has two black children (both nil). It seems like it should be red as well.
@oliverm4633
@oliverm4633 5 жыл бұрын
I had the same question.... Please somebody explain
@fasihkhan8633
@fasihkhan8633 6 жыл бұрын
No words ... hoW to be thankful Great tutorial🔥👍
@juliajeehyunkim
@juliajeehyunkim 3 жыл бұрын
This is AWESOME. Love this video, hope you become more famous
@leenlovesdancing3561
@leenlovesdancing3561 5 ай бұрын
Thank you so much! ☺
@王冠信-o1c
@王冠信-o1c 4 жыл бұрын
Why the 5 on the left side isn't red?
@anukoolsrivastava4235
@anukoolsrivastava4235 7 жыл бұрын
to the point and clear enough
@ruiqiliu3114
@ruiqiliu3114 2 жыл бұрын
Clearly explained, thank you!
@antwanwimberly1729
@antwanwimberly1729 11 ай бұрын
Can you clarify what a NIL descendant is instructor ?? We need more context and clarity.
@ThomasEdits
@ThomasEdits 7 ай бұрын
"NIL" is just the term used for any empty (not used) slots if a node does not have a left-child, the left-child is "NIL" / NULL
@markmcdonnell
@markmcdonnell 5 жыл бұрын
For point 4. "All paths from a node to its NIL descendants contain the same number of black nodes" is that meaning counting from _any_ node to a nil or specifically from the root to a nil? Because if it's the latter, then in the given example that makes sense (5 to nil = 2, 12 to nil = 2, 19 to nil = 2), but then what happens if I insert "24" to this tree and it's added to the right of the red "23"? As far as I can tell we no longer have root to nil counts being 2, but 3 if we were to look for "24" (e.g. 19 to 24 to nil = 3). It seems I have misunderstood the meaning behind this particular point?
@harbl2479
@harbl2479 5 жыл бұрын
@Mark McDonnell When inserting there are specific rules to follow as well. Are you sure you got those right? Otherwise you don’t end up with a valid rb tree
@ioanabiris3472
@ioanabiris3472 Жыл бұрын
Thank you!!
@randomhappyguy6719
@randomhappyguy6719 5 жыл бұрын
Update: I see. A "Nil" node is black. I don't understand 2:27 about the Black Height. Not counting the root, the black height of the tree should be 1 instead of 2?
@Vipe12358
@Vipe12358 5 жыл бұрын
nil is a black node, so you have to count them as well
@geezer2450
@geezer2450 7 жыл бұрын
This (and your other videos) were very helpful! Thank you very much.
@KingUnity22
@KingUnity22 3 жыл бұрын
but how do we determine whether a node is red or black?
@bipinkori4060
@bipinkori4060 6 жыл бұрын
Thank you very much
@palandersmuhlbradt5705
@palandersmuhlbradt5705 6 жыл бұрын
why is node red and black? have the colour any meaning?
@ayushagarwal4253
@ayushagarwal4253 Жыл бұрын
Nice video. Can you also make one on Tries please?
@MichaelSambol
@MichaelSambol Жыл бұрын
will add it to the list 👍🏼 taking a small break to finish some other projects, but will be back.
@ahmadrezamoodi6603
@ahmadrezamoodi6603 5 жыл бұрын
nice and simple.it was all i needed thanks
@chrisjasonmcqueen
@chrisjasonmcqueen 5 жыл бұрын
Awesome video thanks for sharing!
@jeremylee4048
@jeremylee4048 2 жыл бұрын
thank you
@CaveDave
@CaveDave 3 жыл бұрын
to be honest, I did not understand everything in this video. E.g. 1:50 . All paths from a node..... then you add "1" and a "2" next to the five. Don't know what are you counting there, dont know what the numbers are related to?! If you count the NILs then just put the 1 to the left NIL and the 2 to the right NIL....
@pedroalbertogomes3809
@pedroalbertogomes3809 6 жыл бұрын
Hi, I'm teacher at a public university in Brazil. May use your material?
@MichaelSambol
@MichaelSambol 6 жыл бұрын
Sure! Just let them know where you found it.
@rishabhjain2404
@rishabhjain2404 7 жыл бұрын
One of the best sources to learn and revise. Kindly add more videos on concepts like AVL trees, Splay trees etc. Also, can you do a video on random sampling, which is hot topic of interviews these days and I see no one has made on it on KZbin yet.
@marcofontana8308
@marcofontana8308 4 жыл бұрын
frate ti adooroo sei un grande
@lingyongwang2817
@lingyongwang2817 6 жыл бұрын
This is great! Thanks for sharing!
@toastyshrimp1882
@toastyshrimp1882 2 жыл бұрын
what are the other ways to balance a BST besides red black trees?
@crunkbucha4667
@crunkbucha4667 5 жыл бұрын
why is the height two when there's only one black root in the paths to the NIL nodes not counting the root
@lzurzolo
@lzurzolo 5 жыл бұрын
Because every NIL leaf is itself black and is therefore counted in the black height of a node
@alandawkins8297
@alandawkins8297 6 жыл бұрын
very elegant.
@dogemaester
@dogemaester 6 жыл бұрын
Wow great job! I love this!
@kaustubhpandey9654
@kaustubhpandey9654 5 жыл бұрын
Great video!
@ultrafalling
@ultrafalling 5 жыл бұрын
Great useful content! Thanks
@Do-Your-Work
@Do-Your-Work Жыл бұрын
This line " red nodes have black children ".
@jackkirby5287
@jackkirby5287 3 жыл бұрын
What is a NIL node?
@daniellarson8291
@daniellarson8291 4 жыл бұрын
Shouldn't 5 be red?
@melbexdeleon8951
@melbexdeleon8951 6 жыл бұрын
GREAT videos man!
@TheLoyalpain
@TheLoyalpain 7 жыл бұрын
I liked everything except the way you pronounce root... Otherwise very helpful!
@MichaelSambol
@MichaelSambol 7 жыл бұрын
I've always said it weird. :)
@nabinkhadka7168
@nabinkhadka7168 6 жыл бұрын
What is weird about the way he pronounces root? Sounds normal to me.
@antoniojg-b8284
@antoniojg-b8284 6 жыл бұрын
"rewt" vs "ruet"
@codyromano7868
@codyromano7868 6 жыл бұрын
I didn't mind that at all. It added character to the (already well done) explanation. :)
@valeskavictoria1278
@valeskavictoria1278 5 жыл бұрын
@@nabinkhadka7168 He pronounces it as if there aren't any "o"s in the word. It isn't correct or considered to be a normal pronunciation in most of the anglophone world. It's not bad or ugly, but it isn't correct and is indicative of his dialect and region. I would imagine he is from some place in the south of the US, though there are other pockets of similar dialects in the U.S (I don't know about other countries, maybe Canadians do that too sometimes.) I don't say this to shame him or anything, he speaks perfectly fine and I sort of like that pronunciation a little bit, I am only saying this because it seems like English might not be your first language so I just wanted to help. That's all :)
@alfredoespinozapelayo
@alfredoespinozapelayo 5 жыл бұрын
Why is node 5 black?
@RedPandaDesu
@RedPandaDesu 6 жыл бұрын
Good summary of CLRS 3e chapter 13.1.
@dmytromarchuk3023
@dmytromarchuk3023 4 жыл бұрын
succinctly, like
@IjzerKeizer
@IjzerKeizer 6 жыл бұрын
root (r-uu-t)
@Aerosmithism
@Aerosmithism 7 жыл бұрын
Why do NILs have no values (and are not represented as regular Nodes)?
@ThomasEdits
@ThomasEdits 7 ай бұрын
"NIL" is just the term used for any empty (not used) slots if a node does not have a left-child, the left-child is "NIL" / NULL
@de9989
@de9989 5 жыл бұрын
nice video,thanks bro
@trollerninja4356
@trollerninja4356 6 жыл бұрын
y is 5 not red?
@oliveruhlar351
@oliveruhlar351 5 жыл бұрын
Can R-B Tree contain only black nodes ?
@77Raffi77
@77Raffi77 5 жыл бұрын
Yes, e.g. if the tree only has a root
@mohamednofal5256
@mohamednofal5256 5 жыл бұрын
thanks mic
@hurrykrishna
@hurrykrishna 7 жыл бұрын
thank you. made easy!!
@harrisonn9792
@harrisonn9792 2 жыл бұрын
Thank YOu
@pustkaimrok
@pustkaimrok 5 ай бұрын
still no answer why a node is red
@fethiourghi
@fethiourghi 4 жыл бұрын
thanx
@rohitippili3834
@rohitippili3834 6 жыл бұрын
Thanks sir
@buzayehuyitbarek3877
@buzayehuyitbarek3877 4 жыл бұрын
10q Mr Michael
@Jeff-zc6rr
@Jeff-zc6rr 7 ай бұрын
You actually don't explain why a node is red.
@iulianalexandrudragan5531
@iulianalexandrudragan5531 7 ай бұрын
I think it arises naturally from the 4th rule
@Craffunky
@Craffunky 5 ай бұрын
To have the same number of black nodes you need to add red nodes
@jordan1543
@jordan1543 6 жыл бұрын
spectacular, you may come to my bar mitzvah
@MichaelSambol
@MichaelSambol 6 жыл бұрын
Send me the details. :)
@marco.nascimento
@marco.nascimento 5 жыл бұрын
nice
@dhruvamishra5857
@dhruvamishra5857 7 жыл бұрын
pls upload more videos
@kafychannel
@kafychannel Жыл бұрын
interesting )
@Nevverglow
@Nevverglow 4 жыл бұрын
this is gonna be called Red-block tree soon
@jmm00702
@jmm00702 4 жыл бұрын
red-afroamerican tree 4Head
@ZandPyr
@ZandPyr 10 ай бұрын
This is helpful but the talking is very slow.
@motoliao
@motoliao 7 жыл бұрын
Nice!!
@RobertPodosek
@RobertPodosek 2 жыл бұрын
>Every leaf (NIL) is black has 3 red leaf nodes, wut
@TonyKaku-g8n
@TonyKaku-g8n 5 жыл бұрын
You know, every node has a black parent at height 1
@FightTheByte_
@FightTheByte_ 2 жыл бұрын
I'm literally looking at 3 red nill nodes...?
@ondrejmatousek9723
@ondrejmatousek9723 4 ай бұрын
where?
@fireguardianx
@fireguardianx 3 жыл бұрын
I might be wrong, but you sound just like the Khan Academy guy for calculus...
@hangchen
@hangchen 5 жыл бұрын
😊
@thezman2759
@thezman2759 11 ай бұрын
What is the point of these!? I don't get why you would want to manage more information and increase complexity.
@MichaelSambol
@MichaelSambol 11 ай бұрын
So your professors can grill you 😅
@vijaysaikonatham68
@vijaysaikonatham68 6 жыл бұрын
Your concept is wrong , because in red black trees root and leaf nodes should have same color
@adamday5045
@adamday5045 2 жыл бұрын
ruuuuuuuuuuut
@antwanwimberly1729
@antwanwimberly1729 11 ай бұрын
Notice we’re all still alive. Heaven on Earth is real. Germanic Europe approaches
@10bokaj
@10bokaj 3 ай бұрын
ruuurt
@MichaelSambol
@MichaelSambol 3 ай бұрын
tomato / tomahto 😎
@mati124
@mati124 2 жыл бұрын
i hate my life. why i have to learn this nub trees
@isaacruelascastillo4952
@isaacruelascastillo4952 4 жыл бұрын
he said my children were black
Red-black trees in 3 minutes - Rotations
3:05
Michael Sambol
Рет қаралды 305 М.
5.16 Red Black tree | Introduction to Red Black trees | DSA Tutorials
33:00
Jenny's Lectures CS IT
Рет қаралды 757 М.
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 41 МЛН
My Daughter's Dumplings Are Filled With Coins #funny #cute #comedy
00:18
Funny daughter's daily life
Рет қаралды 35 МЛН
MY HEIGHT vs MrBEAST CREW 🙈📏
00:22
Celine Dept
Рет қаралды 79 МЛН
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 12 МЛН
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 404 М.
Red-black trees in 8 minutes - Deletions
8:13
Michael Sambol
Рет қаралды 102 М.
Hash Tables and Hash Functions
13:56
Computer Science Lessons
Рет қаралды 1,6 МЛН
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 488 М.
Quick sort in 4 minutes
4:24
Michael Sambol
Рет қаралды 1,9 МЛН
But what is a neural network? | Chapter 1, Deep learning
18:40
3Blue1Brown
Рет қаралды 17 МЛН
100+ Computer Science Concepts Explained
13:08
Fireship
Рет қаралды 2,6 МЛН
Red-black trees in 5 minutes - Insertions (strategy)
5:38
Michael Sambol
Рет қаралды 480 М.
AVL Trees & Rotations (Self-Balancing Binary Search Trees)
20:38
Back To Back SWE
Рет қаралды 343 М.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 41 МЛН