Regarding the print level tree

yes i m talking about this code only in this video

hello @ssmit_joshi
height is defined as maximum depth from root node to leaf.
here we are recusrive calling the function to left node and right node to find their height.
let say l is the height returned by left subtree and r is the height of right subtree.
then height of current tree will be either 1+l or 1+r right?
which one we will pick?
we will pick maximum among them (becuase height is defined as maximum depth from root node to leaf.).
thats why we are using max
read this for better clarity->link

i m not understamding still that max(0,0) what does it do and how it increase and why it is related to height pls tell

max is function that returns maximum of the two.
here will return 0 becuase max(0,0).
now this result will go to its parent node and that will add 1 to it and compute its height and send the result to its parent and the process will continue till we reach root.

i would recommend to revise recursion , becuse its pure recursion based problem

but for finding height why we have to take maximum number here?

can u pls explain with some examples with good explanation by taking 2 or nodes in left and right so that i will be able to understand easilt

image

     maxDepth('1') = max(maxDepth('2'), maxDepth('3')) + 1
                               = 2 + 1
                                  /    \
                                /         \
                              /             \
                            /                 \
                          /                     \
               maxDepth('2')                 maxDepth('3') = 1
= max(maxDepth('4'), maxDepth('5')) + 1
= 1 + 1   = 2         
                   /    \
                 /        \
               /            \
             /                \
           /                    \
 maxDepth('4') = 1     maxDepth('5') = 1

ok but here actually what max is returning here is different max(4,5) so it should return 5 na ?

yeah . … … …

in example you have provided max 2,3 and 4,5 why it is returning 1 ?

thr number that are written in quotes are not values they are node numbers.
returning 1 becuase they r in the bottom so their height will be 1

then what is the work of max function here then

mx is taking maximum value of left and right subtree.
watch video again if still it is not clear

and what you have told why it is returning 1 pls tell once again properly

height of single node is defined as 1.
refer video again

i have seen again but i am not understanding still that(0,0) return 1 and (1,1) also return one and why plus one is used i m not understanding this all

max(0,0) will return 0 only.
adding 1 to include current node.

ok so in this video it has shown 9 and 7 value so if 9 and 7 will will (0,0) it will retun 1 but about value of 6 it has not null so how it return 2 above

pls reply so thati an understand

reply what? ,already explained everthing