Right View of a Binary Tree

Why it’s throwing error? - https://ide.codingblocks.com/s/417627

Do i need to overload the shift operator?

yes if you want to use this cin >> root;
then you have to overload the >> operator

Will you please help me out with the code for the same?

code is discussed in videos

sir explained the code and then write
follow that approach

watch the videos in series they will help you
so that you can write code at your own

Maximum sum path from any node to node lecture was not complete, please help me out with explanation of that.

Hi Rahul. what doubt are u having??

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.

Why you’ve closed this doubt? The video of maximum path sum from any node to node (19th video) is not complete & I’m not able to write code of it. Please help me out with code of Maximum sum path from any node to node (using pair as discussed by Prateek bhaiya))

For each node there can be four ways that the max path goes through the node:

  1. Node only
  2. Max path through Left Child + Node
  3. Max path through Right Child + Node
  4. Max path through Left Child + Node + Max path through Right Child
    The idea is to keep trace of four paths and pick up the max one in the end. An important thing to note is, root of every subtree need to return maximum path sum such that at most one child of root is involved. This is needed for parent function call.

refer to this code. it contains function for same https://ide.codingblocks.com/s/584348

I got the basic intuition but I’m not able to write code by myself. Will you please help me out with the code?

refer to this code. it contains function for same https://ide.codingblocks.com/s/584348
I think rest creating class, insertion of nodes and all u can do

I want the approach discussed by bhaiya (of creating pair first & then proceeding further). I’ve already referred this approach from GFG :slight_smile:

I mean the one you’ve shared is there on GFG

I have shared this approach because i feel this is the simplest and easiest approach to understand and code

If u have any other difficulty u can share ur code. i will definitely help u if ur code is not working or help in debugging ur code

I’m not sure whether you’ve access to the content or not but bhaiya discussed one approach using pair STL, but the video is not complete, so I’m not having the code. That’s why I’m asking you for help, if you can help me out with that code.

ig this is the code u are looking for https://ide.codingblocks.com/s/584420
hope it clears all ur doubts

I’ll go through it & will try to understand. Hope you’ll not close the doubt till then. Thanks

Sure Rahul… take ur time