Welcome to the community! Glad to read that you are learning about ROOT.
From your posting it seems that there is no ROOT specific issue.
I am convinced that you will learn the most if you solve your homework question by yourself.
However, if you do find a problem, bug, or have a suggestion for improvement, please do come back and let us know.
All the best,
Lukas
PS: Here some tips for efficient and successful posting