homework 6 submission

If r is null, there is nothing to do, just return null.
You can't do r->k because it will crash ... dereferencing a null pointer is not a valid thing to do.