Tree right view

i am unable to do this question .
pls tell the code.

@yutikakhanna
hello yutika,
approach and code->
image