Depth and level of tree

 

Let's look at an example:

                      4️⃣                        - > Level = 0   

                 /          \         

              3️⃣              5️⃣               - > Level = 1

           /      \          /     \

        1️⃣        2️⃣     6️⃣       7️⃣         - > Level = 2

 

The level is the depth of a set of nodes in a tree.

Depth of a tree is the maximum depth of a node in the tree

 

                      4️⃣                        - > Depth = 0 

                 /          \         

              3️⃣              5️⃣               - > Depth = 1

           /      \          /     \

        1️⃣        2️⃣     6️⃣       7️⃣         - > Depth = 2

 

Discussion

3

0