CSC148H1 Lecture Notes - Lecture 22: Binary Tree, Branching Factor, Eval

77 views4 pages
13 Mar 2018
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

References: code seen in the pictures can be on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter. One approach to binarytree would be to make it subclass of tree, but there are some design considerations: any client code that uses tree would be required not to violate the branching factor of binarytree. 1 way to achieve this is to make tree immutable: make sure there is no way to change children or value, have subclasses that might be mutable. However, it is easier to make a completely separate binarytree. Change generic tree design self. left, self. right = left, right: 2 children named left and right. Standard special methods: __eq_, __str_, __repr__ Implemented contains on linked lists, nested python lists, general trees. Modify this function so it becomes a method. Height = 1 + the maximum path length in a tree. A node also has a height, which is 1 + the maximum path length of the tree rooted at that node.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents