Lecture #7: Data Abstraction
Reprise: An Abstract Data Type (or ADT ) consists of
The simplest ADTs are not particularly abstract: they are a collection of data values and their behavior consists entirely of selecting
or modifying those
Lecture #4: Higher-Order Functions
A Simple Recursion
The Fibonacci sequence is defined
Theta Tau rush events, starting 1/31. See Piazza post.
CSUA Unix/Emacs help sessions: Thursday 1/26, Tuesday 1/31, Thursday 2/2 in 310 Soda, 68PM.
Lecture #8: Sequences
A Recursive Definition
The term sequence refers generally to a data structure consisting
of an indexed collection of values.
That is, there is a first, second, third value (which CS types call #0,
#1, #2, etc.
A sequence may be fi
Lecture #6: Abstraction and Objects
Pig Contest Rules
The score for an entry is the sum of win rates against every other
All strategies must be deterministic functions of the current score!
Non-deterministic strategies will be disqualified.
Lecture #3: Recap of Function Evaluation; Control
Announcement: Triangle Fraternity for Engineers, Architects, and Scientists Spring Rush 2012 This Week! Visit caltriangle.org for information.
Environments map names to values.
Lecture #2: Functions, Expressions, Environments
From last lecture: Values are data we want to manipulate and in
Were going to use this notation to denote functions:
Functions are values that perform computations on v
Lecture #5: Higher-Order Functions
Do You Understand the Machinery? (IV)
What is printed: (1, infinite loop, or error) and why?
Hackers @ Berkeley is hosting their second annual HackJam 2.0
hackathon, this Saturday at 2 pm, in the Wozniak
Lecture #11: Strings, Mutable Data
Strings: A Specialized Type of Sequence
Strings are sequences of characters, with a good deal of special
Rather odd property: the base cases are circular. Characters are
themselves strings of length 1!
Welcome to CS61A!
This is a course about programming, which is the art and science of
constructing artifacts (programs) that perform computations or
interact with the physical world.
To do this, we have to learn a programming language (Python
Lecture #15: OOP
From Last Time
Just as def defines functions and allows us to extend Python with
new operations, class defines types and allows us to extend Python
with new kinds of data.
The Account type illustrated how we do each of these
CS 61A Midterm 1 Study Guide Page 1
mul(add(2, mul(4, 6), add(3, 5)
add(2, mul(4, 6)
A name is bound to a value
Red arrow points to next
CS 61A Midterm 2 Study Guide Page 1
nonlocal <name> , <name 2>, .
Effect: Future assignments to that name change its
pre-existing binding in the first non-local frame of
the current environment in which that name is bound.
Tuples are immutable sequences.
Lecture #16: (Mostly) Interfaces and Generic Functions
Using Base Types
Sometimes, we want an overriding method in a subtype to augment
rather than totally replace an existing method.
That means that we have to call the original version of the method
Lecture #14: Dictionaries and Classes
Dictionaries (type dict) are mutable mappings from one set of values
(called keys) to another.
# A new, empty dictionary
> cfw_ brian : 29, erik: 27, zack: 18, dana: 25
Lecture #9: Operations on Sequences
Another Higher-Order Operator: reduce
Weve seen a generalized way to accumulate a result in homework:
def accumulate(combiner, start, n, term):
total, k = start, 1
while k <= n:
total, k = combiner(total, term(k), k +
Lecture #13: Lists, objects, and Arrows
Diagrams of Sequence Objects
Weve often depicted values as arrows to something. To illustrate
x = (1, 2, 3) you might see:
The value of x here is the arrow, not the box (object) at the end.
Lecture #12: Mutable Data
Quick Feature Review
Announcement: UPE, the L&S CS Honors Society, is hosting a resume
workshop in preparation for the Career Fair next week, and theyll be
going over some resume tips and doing one-on-one resume critiques. Its