Empty structure versus a zero value

A program totals values in a finite binary tree with no cycles or shared nodes. Each nonempty node has value, left and right fields, and an empty child is None. Select every correct statement about the function.


Python
def total(node):
    if node is None:
        return 0
    return node.value + total(node.left) + total(node.right)
Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Structural Recursion Questions: