Function Recurssion: [duplicate]

Once execution hits the return statement with the two function calls it first calls nodeDepths(node-> left, depth + 1) and execution continues until this returns. Then nodeDepths(node->right, depth + 1) is called and once this has returned we finally add the results and return them. Note that it isn’t necessarily going to call the functions in that order though.

Leave a Comment