 Now let's say for our sake I wanted to come in and I wanted to insert an element I wanted to come in and let's just because I arbitrarily made some space here. I wanted to insert 35 So how would I go about doing this? The first thing I need to do is find where we're in my skip list to insert it We know yes, it magically is here But we still have to kind of treat this as if we were a machine a robot So we do have to go through that same process of doing our look up No Yep, we come through we skip over No Yep, we skip over No, you can jump ahead really quickly if you need to I'm almost done Yep, nope. Yep Nope Or yep and No, so I know I can't go any further than 35 39 this finally tells me where to put my 35 So da-da-da-da I come in and I have my 35 Huzzah Now the big important question is if we notice if I just did that all the time that was it that then What would happen if I in I do like 800 more inserts? They're all just going here at the bottom So one of the things we also have to do is we have to determine how much it goes up How many levels does 35 go up now? This is going to actually surprise you but in the just truly generic sense of a Linked a skip list. I just go up some random number. I know some Go up some random Number For our sake, I do kind of have a capping point. I don't want to input here if I don't have to You know, so maybe five plus one. I can go up to six levels In our sense and for my sake, I will actually Play the roll of random. Oh, you can already see I've been practicing So flip a coin I Flipped a coin Tails. All right. Well, that means I'm done. Goodbye. No, let's go ahead and argue Say I flipped and I got a heads in this case Well, that means that I would come up here and I would add 35 again So let's flip it again Heads heads means that guess what I come up and I add it to the next level. This is sort of my Way of implementing it. I'll flip it one more time Quote in quote one more time. Nope. I gotta flip it again Welcome to sort of this is apparently a very important element inside here. So cross your fingers Tails oh man love the random so I stop here now that's not the best Implementation someone out there on the internet's gonna be like that's a terrible, you know, why random it's always, you know I can return know all the time Yes, that's actually a great area of research of determining how levels how high levels up in a skip list go So if you're actually curious, that's one of the things you can do So since I'm already here, what happens if I then in turn came down and I wanted to do a remove and For our sake, I'm gonna say remove 17 So let me clear off my board for just a second So like I just said, I want to come in and do a remove 17 Well, just like we did with my insert of 35. It doesn't matter that we're not it's not here It won't actually affect us too terribly much, but I Start once again, and I have to find the location of 17 assuming 17 all exists in here for our sake It doesn't or it does so I get it Now this is the easy part as you can imagine. I simply delete this I remove it out of the skip list if we're thinking about this in an implementation since This is a node, right? that has Infinity in it. That's a little too small. Let me Make it a little bigger That had negative infinity in it and it was pointing to 17 we now just point it to our Positive infinity that same thing is gonna happen because I have to go down. I have to go down every level Remove it again. This tail is gonna go here. I go down a level Not tail. Sorry next I remove it Next is gonna change to the next element Come through here That look it's not just there. It's 12 now has that Finally on this last element it gets removed The reason why I'm kind of explicitly doing all this stuff out is because one of the things I want to think about And I'm gonna kind of get rid of it. Let's say I came in and 17 no longer exists Well, you might notice I happen to have two levels That are both just positive and negative infinity and that's it So one of the other things I do since I've stripped out my That's a terrible. That's not the color. I want I think this is a little darker. It'll work Hmm and there Since I have these two levels and I don't you know, it's that's a little bit of a redundant issue I start basically getting rid of top levels until I only have One of these left. So in essence that s5 Also gets removed and as many Levels as possible if there were you know two levels of 17 that were by themselves and I deleted 17 I would do the same thing but in this sense I do have to get it until I only have one level the top level and in this our world of positive and of negative and positive infinity