COMPSCI 61A Lecture Notes - Lecture 20: Mutation, Linked List

22 views4 pages
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

Set literals are enclosed in braces, but no colons. Duplicate elements are removed on construction no duplicates. Sets have arbitrary order, just like dictionaries. S = {3, 2, 1, 4, 4} Once you have a set, add element with . add(element) What we should be able to do with a set. Membership testing: is a value an element of a set. Union: return a set with all elements in set1 or set2. Intersection: return a set with any elment in set1 and set2. Adjoin : return a set with all elements in s and a value v. Doesn"t change original, creates new set and adds new one. Proposal 1: a set is alinked list taht contains no duplicates. Make sets ordered so that we can improve our order of growth. Implement set operations ordered linked lists, first, rest, == Def contains(s, v): if empty(s) or s. first > v:

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