 So we're now left with our last structure that we have to look at, aptly known as the ZIG Zag. So let's say for example I came in and I did an insert on, I don't know, 30. So in this case we see that we have our structure. We still have 75 being the root node since it was just inserted. We have a 50. We have a 25. So normal binary search tree rules apply. 30 is less than 75. It's less than 50, but it's greater than 25. And so as a result, you'd notice that it's going to come here. It's going to be set up in this way that it's now sort of our, our whatchamacallit, that's don't ever say whatchamacallit, our child node. Well, we're stuck because we're no longer dealing with sort of the ZIG Zag formation or the formation of our ZIG approach because I do have a grandparent. Here's my X, here's my Y, here's my Z. We'll get to 75 in just a second. So what do I need to do? I'm going to focus primarily on these nodes first, just these three nodes. Like I said, I'll get to 75 in a little bit. So a ZIG Zag approach. As you can kind of see once again, has grandparent and the relationship between the grandparent and the parent and the relationship between the parent and our, our node are different, different relationships between Z and Y and Y and X. So what do we do? Well, we've already seen this actually when we were dealing with AVL trees to begin with and that was known as a trinode restructure. And the entire premise is what I'm going to do is I'm going to make sort of my X become the root node of this small little block. So I'm not the root node of the tree just yet. Again, we still need to make it go to the top of the tree, but for right now what we're going to do is we're going to move it to right about here. We're going to move it to the root of this kind of grouping here. So as a quick refresher, if you will, if I happen to have some Z and I had some Y and I had some X, that's one structure, very similar to ours. But it's not the only one. I could also do the exact opposite where I have a Y and I have an X, except for the roles have been reversed. My Y is the right child and my X is the left child. Now again, we're doing a trinode restructuring, which means I need to once again establish which node is my A, which node is my B, and which node is my C. So if we're following sort of this structure that we'll go off of, once again we're looking for the in-order relationship. In-order, which means left, self, right. Now in the example we're looking at here, I actually would not make Z my A. In my previous videos, we've done a lot of Z's to A's first. However, instead, I would go to my left child first. I'd absolve to go to my left. Now I'm at Y. It doesn't mean I magically pick Y first. Since I see Y has no left child, I would pick Y. This will become my A. My A. Then I would access my self. That's why I would do this. Then I get to access my right. Now I'm still right here. I don't just restart back at Z. I would see that I have a right child at Y, and that's my X, and so that would become my B. Now since I'm done, in this case, my Z is the last thing, so it would become my C. In this example, just to kind of see it, Z would become A, X would become B, it's still B, and then Y would become C. Now once again, once I've taken this structure, I take my nodes and whatever B is, that becomes the new parent. Whatever A is becomes the left child, and whatever C is becomes the right child. So let's take this approach. Let's apply it to what we've been seeing so far. So in our case, I still have, and I'll draw it all out, I still have a 75 as my root. I have a 50 as my Y, and I have a 25 as my, actually that's my Y, and I have a 30. That's my X, that's my Y, that's my Z. So once again, if I take the approach that I just said, I make the in-order approach, I take my A, B, and C, and I apply this, I'm going to see that my B is going to become my new root. So I take this approach, I apply tri-node restructuring. 75 still has not been touched, that's fine, we'll get to it. My new root here is X, so that's where 30 is actually going to go for the time being, Y is going to get put here, and Z is going to get put here. So I've been saying it a few times though, we're not done. X happens to be here now. This is, you know, where we just happened to have established where I am in my tree, and so what do I do next? Well, the entire idea of a splay tree is we move to the root. I'm not at the root yet. So what structure do I have? Well, I happen to know that there's no Z, there's no grandparent, so of those three, once again we can play the operation of which structure am I looking at? Am I looking at a zigzag where I have a grandparent? Well, no. Am I looking at a zig-zig where I have a grandparent? Well, no. Instead I'm looking at a simple zig, where I have no grandparent, and as a result, since I have no grandparent, I make a simple rotation. In our case, I make a simple rotation to the right. Now you notice this is where things are getting a little interesting, because I have some subtrees and a parent, and so where do they all go? Again, I have a T1, I have a T2, and I have some mysterious unknown T3. As I make my rotation, the T2 is going to be flipped and be given to my, in this case, Y. So, to finalize this entire approach, I've gone in, I've made my flip, and so to finish my design, 30 or X is going to become the new root. My Y or 75 becomes my new right child. 75 is going to get T3, we see T3 is nothing. 75 also gets T2, which happens to be 50, and 30, my X, my root, also is going to get my T1, and so there's my zigzag.