And this lecture, we are going to go over the solution to the assignment from the previous lecture,
and that was to implement in the SEO method.
So we are now going to go over it.
So again, as I said, it was going to be very similar to what we did for Floor.
So we're going to have matching on our value.
We're going to have some key and with this some key, we're going to match on key and then compare the
value.
And so what we match on is if it is ordering less, which means that our key is less than the value,
then we will match on self, right?
And we will say some node node dot seal on the value.
Otherwise, none return none.
All right, so now that we're done with ordering less, we do ordering greater.
And then here again, now we're going to go on matching to the left, say some node
and let vao equals node dot seal on our value and then we want to match on the value.
And because we don't care what the value is, we want to just return the value.
Otherwise, we just want to return our key.
Right.
So just remember, we're getting our value here.
We're calling ceiling on the value.
And if this is the value that we want to return, then we return our value.
Otherwise we just return our some key.
And now we say some key here to be exhaustive for this match statement.
We now need to close out the exhaustion for our equals or for our ordering, which means we can have
an equal, which means that we just want to return our key.
And then lastly.
We want to be exhaustive on our overall match statement and return none if needed.
So as I said, the SEO method is going to be very, very similar to our floor method.
Like very similar.
What are our differences here?
We have less.
Less instead of less.
Having all this logic greater has the logic now.
That way we get the greatest the least greatest value above our argument being passed in.
So now we just need to test out our SQL method and we have our test cases already created.
So let's run cargo test and it seems I have some syntax errors expected.
I identify or found keywords.
So let's go to 146 and see what I did wrong here.
So I said ordering less.
It would help if I added that in.
Let's see if that fixes it for me.
Expected here.
So 164 let's get rid of that and try it.
And now it looks like we're still running successfully.
Are floor and SEAL methods were executed correctly?
So sealing is working as desired.
So we pass into six and our tree the greatest least value above six that is in our tree is seven.
And then when we pass in 4043 is the least greatest value above 43 in our tree.
So hopefully this made sense to you and you enjoyed implementing in our very own binary search tree.
If you have any questions, please feel free to ask them in the Q&A section and in our next section
we will begin talking about dynamic programming.