Now the second homework problem is a bit more
involved. Still not too bad but it requires a
bit more code. So we start off by initializing
the SplayTree and we have a few variables to
keep track of the current min and max as
we are going through. And we check whether the
empty SplayTree is actually empty, that is, isEmpty method
returns true. And similarly for findMin and findax, and sent
either can't be any min or max. And
that when we search an empty SplayTree that we
also return none. Now we insert 100 in here, and we set the current min and max
to be 100, just to initialize the tree
to something, and now we go through, and, for
10 examples we check whether the tree is
empty and it shouldn't be. Then we insert it,
insert a new key into the display tree for range
10 through 20 twice, just to see if that works
okay. Update current_min and current_max. Now we checked that that
has been inserted by trying to find it in the SplayTree,
and we assert that that should be found and it
should, find should return the current of the for loop
as found, and this is what we assert here. Now
we check the min and the max; the max shouldn't change,
since we're going from 10 to 20 and we've already inserted
100, but the min should change each time. So this should test,
the findMin function right here. And now we do the same
thing except we try to remove. And we just try to remove
these, assert that it's not empty, and that we don't find,
after removing the key, the key in the SplayTree, because it shouldn't
be in there anymore. And then just as a little, aside here,
we, try to insert 373 and remove it, to see what happens.
This is really not too involved. You could have gotten quite a bit
more advanced with this. This should do everything you need to do. So,
if we run this, we see we got it right. So, I hope
you had fun with this. Sorry about the bug that was in there
initially. And thank you to everyone who caught that, my fault entirely. So,
other than that, I hope you enjoyed this. I hope it showed you
what coverage can and can't do, and after this we'll be moving on
to random testing which I hope you'll also really enjoy. Thanks a lot.