The function foo(p) recursively computes the sum of the subtree rooted at node p (post-order traversal: left child, right child, then the current node), prints this subtree sum, and returns it.
Let us trace the function calls starting from the root node 10:
foo(10) evaluates 10 + foo(5) + foo(11):
Calls foo(5), which evaluates 5 + foo(3) + foo(8):
Calls foo(3): both children are NULL, so retval = 3 + 0 + 0 = 3. Prints 3 and returns 3.
Calls foo(8): both children are NULL, so retval = 8 + 0 + 0 = 8. Prints 8 and returns 8.
For node 5, retval = 5 + 3 + 8 = 16. Prints 16 and returns 16.
Calls foo(11), which evaluates 11 + foo(NULL) + foo(13):
Calls foo(13): both children are NULL, so retval = 13 + 0 + 0 = 13. Prints 13 and returns 13.
For node 11, retval = 11 + 0 + 13 = 24. Prints 24 and returns 24.
For the root node 10, retval = 10 + 16 + 24 = 50. Prints 50 and returns 50.
The complete sequence printed is 3 8 16 13 24 50, which matches option (C).