We normally don't do homework for a person, but since it is a homework assignment it means it definitely been done before so googling should find you an answer.
You might want to post the code for the functions in question.
The expected output doesn't look like what should be expected to me - sure you got that right?