But I was no longer referring to #7. I was referring to #1 and to ways which might render it not necessarily clearer, but more sophisticated. Perhaps coming up with a better algorithm altogether. Can...
Type: Posts; User: peripatein
But I was no longer referring to #7. I was referring to #1 and to ways which might render it not necessarily clearer, but more sophisticated. Perhaps coming up with a better algorithm altogether. Can...
But other than that, can you come up with a more elegant/sophisticated code to yield the same output?
Preferably shorter!
I could have used more variables, agreed. But how may I improve the function I opened this thread with?
It is given that in this section the tree could not be empty.
I first coded it thus, but figured my above code suited better. What do you think?
int findMaxDepth(Node * tree){
if (!tree)...
depth 0. I have tried your code and it gave 7 where it supposed to have given 6 (and whereas my code gave 6).
But that returns maxdepth + 1, and not the actual maxdepth.
Hi,
I wrote the following function to determine the maximum depth of a binary tree, but it feels somewhat cumbersome to me. I'd truly appreciate it if you could help me improve it (make it shorter...