1 / 7

Sets

Sets. Model Notation Sub-Sets Operations (abstract) Operations (ADT) Specialized ADTs based on Set. Sets – the Model. Set: a collection of elements (members) without repetition {a, b, c, ... } Usually, there is a linear order specified on the members specified somewhere else!

hamlet
Télécharger la présentation

Sets

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sets Model Notation Sub-Sets Operations (abstract) Operations (ADT) Specialized ADTs based on Set CS 303 – Sets Lecture 8

  2. Sets – the Model • 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

  3. Set Notation • {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

  4. Sub-Sets • 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

  5. (abstract) Set Operations • 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

  6. Set ADT - Operations • 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

  7. Specialized ADTs based on SET • UID – Union, Intersection, Difference • IDM – Insert, Delete, Member (Dictionary) • I(DeleteMin) – Insert, DeleteMin (Priority Queue) • ...and more...much more... CS 303 – Sets Lecture 8

More Related