Can you tell me why am I not getting the correct output even though my code seems right?
The code is at https://ide.codingblocks.com/s/181113
Right View Tree not working
Your code is absolutely correct. Except lines 45 and 46. Just swap those lines and you would get an AC.
It is because you are supposed to find the right view of the tree and you are calling the left tree before right so just change that.
I hope it helps.
I did that exactly as you told but I got wrong answer. Please tell why wrong answer here?
Your code for building might be slightly wrong. I couldn’t find any error in your code.
Have a look at this for reference : https://www.geeksforgeeks.org/print-right-view-binary-tree-2/
@aman.tandon3096 I cannot see you have done as I told in your code. Please send me your latest code.
Also in your buildtree function you have assigned garbage value to your root node.
Thanks, issue resolved for me.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.