Right View of Tree. Help needed in debugging

My code is showing the wrong output. Could you tell where I am going wrong?

Your algorithm of finding the right view of the tree looks fine. There might be some issue with building the tree.