Question: # A Node is an object # - value : Number # - children : List of Nodes class Node: def __init__(self, value, children): self.value

# A Node is an object

# - value : Number # - children : List of Nodes class Node: def __init__(self, value, children): self.value = value self.children = children

exampleTree = Node(1,[Node(2,[]),Node(3,[Node(4,[Node(5,[]),Node(6,[Node(7,[])])])])])

# Objectives: # (1) Write a function to calculate the sum of every node in a tree (iteratively)

def sumNodes(root): pass

# (2) Write a function to calculate the sum of every node in a tree (recursively)

def sumNodesRec(root): pass

################################# # Objectives: # (1) Write a function compose, which takes an inner and outer function # and returns a new function applying the inner then the outer function to a value

def compose(f_outer, f_inner): pass

################################# # Bonus ################################# # Objectives: # (1) Create a string which has each level of the tree on a new line

def treeToString(root): pass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!