Class Notes (836,991)
United States (324,832)
COMPSCI 61A (133)
De Nero (43)
Lecture 11

# CS61A Lecture 11: Sequences

3 Pages
73 Views

Department
Computer Science
Course
COMPSCI 61A
Professor
De Nero
Semester
Fall

Description
Sequence Abstraction No one sequence class or abstract data type Collection of behaviors: Length. Finite length Element selection. A sequence has element corresponding to non-negative integer index less than length, start at 0 for first element Built-in syntax for sequence Tuple is a kind of sequence, tuple can be more than 2 elements odds = (41, 43, 47, 49) len(odds) odds[1] odds[0] * odds[3] + len(odds) odds[odds[3]-odds[2]] Box and Pointer Notation The Closure Property of Data Types A method for combining data values satisfies the closure property if: Result of combination can be combined using same method Closure is key to power in any means of combination because allow create hierarchy structure Hierarchal structure made of parts, which are made of parts, etc. Tuples can contain tuples as elements Recursive Lists Implement recursive lists as pairs, Use two-element tuple A recursive list is a pair: First element of pair is first element in list Second element of pair is rest of the list empty_rlist = None def rlist(first, rest): """Return a recursive list from its first element and the rest.""" return (first, rest) def first(s): """Return the first element of a recurs
More Less

Related notes for COMPSCI 61A
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.

Get notes from the top students in your class.

Request Course
Submit