- 115 Views
- Uploaded on
- Presentation posted in: General

Sets

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Sets

Model

Notation

Sub-Sets

Operations (abstract)

Operations (ADT)

Specialized ADTs based on Set

CS 303 – Sets

Lecture 8

- Set: a collection of elements (members) without repetition
- {a, b, c, ... }
- Usually, there is a linear order specified on the members
- specified somewhere else!
- not based on “position”
- Well Defined: if a,b S, then either a < b, a = b, or b < a
- Transitive: if a,b,c S, then (a<b) and (b<c) implies (a<c)

CS 303 – Sets

Lecture 8

- {1, 2, ..., 1000} = {x | 0 < x <= 1000}
- {1, 4} = {4, 1} <> {1, 4, 1} (which is not a set!)
- Membership
- x A - x is an element (member) of A
- x A - x is not an element of A
- Null Set
- NULL

CS 303 – Sets

Lecture 8

- A is a SubSet of B
- A is included in B
- B is a SuperSet of A
- A is a subset of A
- NULL is a subset of A
- If A is a Subset of B and B is a Subset of A then A = B
- if A is a Subset of B and A <> B then A is a proper subset of B

CS 303 – Sets

Lecture 8

- Union: A union B = {x | (x is in A) OR (x is in B)}
- Intersection: A intersect B = {x | (x is in A) AND (x is in B)}
- Difference: A-B = {x | (x is in a) AND (x is NOT in B)}
- [show Venn Diagrams]

CS 303 – Sets

Lecture 8

- MakeNull(A): A = NULL
- Member(x,A): b = (x is in A?)
- Union(A,B,C): C = A UNION B
- Intersection(A,B,C): C = A INTERSECT B
- Difference(A,B,C): C = A – B
- Equal(A,B): A == B?
- Assign(A,B): A = B
- Insert(x,A): A = A UNION {x}
- Delete(x,A): A = A – {x}
- Min(A): x = a | (a in A)
- and for all z in A, a <= z
- Merge(A,B): if A INTERSECT B is NOT NULL
- then C = A UNION B,
- else UNDEFINED!
- Find(x): A = Ai | x is in Ai
- if U = {Ai | i<>j
- implies Ai INTERSECT Aj = NULL}

CS 303 – Sets

Lecture 8

- UID – Union, Intersection, Difference
- IDM – Insert, Delete, Member (Dictionary)
- I(DeleteMin) – Insert, DeleteMin (Priority Queue)
- ...and more...much more...

CS 303 – Sets

Lecture 8