COMPSCI 61A Lecture Notes - Lecture 19: Mutation, Memoization
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
If x and y are two objects the equality test, x == y, does not automatically mean what you want it to mean. Tree(4) != tree(4) but after performing x = tree(4), x == x. The reason for this is that in python. All values are in fact pointers to objects, and. By default == on pointers compares the pointers themselves( are these pointing at exactly the same object) That is, by default == and != are the same as the is and is not operators. That can be changed on a class-by-class basis. For example, == on numbers, lists, tuples, strings, sets, dictionaries means what we expect: the contents are the same str tells us what the print function prints out. Repr tells us what to tell the interpreter. Defined as the largest one length to the farthest leaf. Removing subtres from a tree is called pruning. T. branches = [_____ for b in t. branches if t. label != 1]