Class Notes (835,116)
CSC148H1 (92)
Lecture

Exercise 4 B answers These are the answers for part B of the fourth exercise for study purposes. This is the way i did them so i'm sure there are other ways that are possibly better than mine but these are correct. ***Make sure you download the Node fi

2 Pages
126 Views

Department
Computer Science
Course
CSC148H1
Professor
Steve Engels
Semester
Winter

Description
from node import Node from e4a import * def sum_to_deepest(root): ''' blah ''' if root == None: return 0 return sum_to_deepest_helper(root, 0, 0)[0] #return height(root, 0) # helper function that returns the depth of the path and the sum def sum_to_deepest_helper(root, cumulative_sum, depth): ''' blah ''' depth += 1 if root.left == None and root.right == None: return (root.key + cumulative_sum, depth) left = (0, 0) right = (0, 0) if root.left != None: left = sum_to_deepest_helper(root.left, root.key + \ cumulative_sum, depth) if root.right != None: right = sum_to_deepest_helper(root.right, root.key + \
More Less

Related notes for CSC148H1
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.