Download presentation
Presentation is loading. Please wait.
Published byWidyawati Johan Modified over 5 years ago
1
Sets Model Notation Sub-Sets Operations (abstract) Operations (ADT)
Specialized ADTs based on Set 4/17/2019 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) 4/17/2019 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 4/17/2019 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 4/17/2019 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] 4/17/2019 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} 4/17/2019 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... 4/17/2019 CS 303 – Sets Lecture 8
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.