 So now what if I were to take that newly revised tree and give it an insert 75 our normal binary search tree rules apply And so as a result 75 would come to the right of 50. However, this is where we run into a new kind of Example we were talking about how a zig had no grandparent But we noticed that 75 happens to have a grandparent and so what we call this is Something we like to describe as a zig-zig so the idea behind a zig-zig kind of structure is it has a parent it has a parent and Grandparent but that's not the only thing that makes it a Zig-zig if we take a look at the relationship between parent and grandparents I'm gonna go ahead and give them sort of the same values So if I happen to have some z some grandparent some y and some X some node The relationship between the z and the y is going to be the same as the relationship between the y and the x Notice what I mean here if I take a look at the relationship The y is the right child of the z Same kind of things going on here with x the x is the right child of the y so I would say node Has same Relationship relationship with parent y as Y has With grandparent Z Again, this applies on both cases So I could also happen to have some grandparent with some left child and that having some left child So I've Established what a zig-zig structure looks like how do I resolve it so the things that we have to do are Similar to a trinode restructuring, but slightly different. So if I come down I'll just make it so that we can see This structure one more time What I want to do is I want to take this x and And move it to root But by doing so I still need to maintain the binary search tree laws I can't just make 75 here because then where do I put the 25? Oh, I put it here then so How I structure this is I look at my subtrees as we've established even though there's nothing here there's sort of a potential subtree one a potential Subtree two and a potential sub three a Subtree three and four Here So what I'm going to do is I'm going to effectively tilt this over using the parent as sort of my my tilting block and That will cause x to be the new top So in this case you see that x will become the new top Y will become sort of that Left child of x and the grandparent is now going to become the child of x you can actually see basically if we Find ourselves in a right zig-zag. We just turn it into a left zig-zag with you know x and y We're reversed. I don't want to say that like definitively because Little parts of me inside are going no don't don't do that But the beam important thing is where do I put t1 t2 t3 t4? Because even though we're dealing with only three nodes right now. This is always going to be the case Well, if we happen to kind of work it we would put t1 on z and we would put t2 on z The entire premise is as always t1 is less than z so it happens to be the left child t2 happens to be greater than z but still less than y well We happen to notice that's less than y being a left child and greater than z As you can see we would continue this same sort of pattern where y gets t3 because It's greater than y but less than x greater than y but less than x and x would get t4 So if we were to apply the zig-zig sort of tilt if you will to our current tree what we should see is that 75 is going to become the new root 50 is going to become the sort of parent the why and 25 will be the new leaf node Just as a once again stressing this fact. We're no longer dealing with trying to make something a balanced search tree We're dealing with something being moved to the roots again AVLs were self-balancing Splays on the other hand are not they're just whatever was the last access node it gets to go to the top