for anyone watching this in the future: dont forget to let the node's parent know that now THIS node on the top is it's left or right child, not the one it was previously pointing to. i dont know how the implementation shown here can work, but i was debugging this whole day to figure that out. (C++) other than that, those videos have been great and really helped me a lot, so a big thanks to you Rob Edwards. Great lessons!
@moody543244 жыл бұрын
Hey i did not get that, where should i change my code to work? In rebalance ? Or rotateLeft?.
@Enlightenchannel2 жыл бұрын
Hey, nice to know someone else spent a whole day debugging this too. Two years ago. I was looking at the comments on the rotations video instead of here. This would've saved me ALOT OF TIME If I'd seen it.
@rahulbawa67324 жыл бұрын
The parent is not being assigned in the rotate left/right functions.
@codybontecou7 жыл бұрын
Wish he went over the height() function he uses. Unsure of how he's keeping track.
@lukaskun64317 жыл бұрын
My implementation for my AVL Tree in C#. Not sure, if it is conceptually same as the one in this lecture, but you can take this at least like an inspiration: private int Height(Node node) { if (node == null) return 0; int left = 0; int right = 0; if (node.Left != null) left = Height(node.Left) + 1; if (node.Right != null) right = Height(node.Right) + 1; return right >= left ? right : left; }
@leonazraev49026 жыл бұрын
the return doesnt need to be right + left ?
@sonamSelects6 жыл бұрын
Leon Azraev no the height is the length of the longest path to a leaf node.
@felipegodias6 жыл бұрын
kzbin.info/www/bejne/fIC3mIOQjr53r7M
@ayushkashyap82994 жыл бұрын
int height(node* t) { if(t==null) return -1; else return 1 + max(height(t->left), height(t->right)); } Note: Height of a single node is 0 in the above code if you wan't height of single node to be 1 the replace -1 with 0
@Aggabummbumm7 жыл бұрын
Can this also be used for deletion?
@x_zero9943 жыл бұрын
I wrote the code, but the root didn't change!! and after applying the rotations it didn't print the hole tree when I tried to, Does anyone knows why?
@logiconabstractions65967 жыл бұрын
Am I tripping or this guy is writing backward^ That in itself is impressive. The video itself is also quite good - I am to implement a map data structure using AVL trees. I think this makes the gist of it really clear. Thanks.
@BrianFaure17 жыл бұрын
Pretty sure he's just writing regularly then flipping the video horizontally in post-production.
@MrSkopelos277 жыл бұрын
Yeah it's mirrored. Look at the Nike logo on his tshirt.
@ahmadbukhari28093 жыл бұрын
This guys is great, all the videos are super helpful but this method does not make sense. There are soo many missing validation and there are missing points.