I need to write a program to find the sum of depths of a binary tree, where a depth is by definition the shortest distance between a node and the root. I am required to code this using recursion.
I was thinking of first coding a helper recursion to find the depth for each node. What would be the best way to do that?
PS if I could move from the node to the root, I believe programming this helper recursion would not be very difficult. Is there a way to progress from the node to the root?