Lecture Tree Class A Tree has a label and a list of branches; each branch is also a Tree class Tree: def __init__(self, label, branches=[]): self.label = label for branch i...
CS61A: Lecture 22
CS61A: Lecture 23
Measuring Efficiency Efficiency is the measure of how long our program would take to run. Ex: The recursive computation of the fibonacci sequence def fib(n): if n == 0: return 0 ...
CS61A: Efficiency
Measuring Efficiency Efficiency is the measure of how long our program would take to run. Ex: The recursive computation of the fibonacci sequence def fib(n): if n == 0: return 0 ...
CS61A: Composition
Linked Lists A type of recursive data structure that stores a sequence of values. A linked list is either empty a first value and the rest of the linked list Thus, a...
CS61A: Representation
String Representations An object value should behave like the kind of data it is meant to represent Part of this ability is to provide a string representation of a program T...
CS61A: Inheritance
Inheritance A method for relating classes together. A common use case is two similar classes that differ in their degree of specialization The specialized class has same attributes as a gene...
CS61A: Lecture 21
Lecture Composition A linked list is a recursive data structure that represents a sequence. List Efficiency - Fast Appending, assigning, and list comprehensions are fast The...
CS61A: Attributes
Attributes Method Calls Method calls differ from function calls because they are invoked with dot notation. <expression>.<name> The <expression> can be any va...
CS61A: Objects
Object-Oriented Programming OOP provides a method for organizing large programs large programs can be organized into small, modular components that can be developed at ones. Ext...
CS61A: Lecture 17
Objects Review - Mutability What would be the final values of the names defined within this code segment? def func1(lst1): lst1 = lst1[0:-1] return lambda lst: lst + lst1 def func2(ls...