Sets Flashcards
What is specification?
Description of what the type does and the method it provides to do it.
What is implementation?
Code that actually does the work
What is a set?
A set is a group of things, either related or unrelated.
Does a set have to contain a group of things which are related?
No, it the set can contain either related or unrelated elements.
Does the order within a set matter?
No
Do sets contain duplicates?
No
What does ‘aEs’ mean?
‘a’ is a member of set ‘s’
What does ‘4E{1,2,3,4}’ mean?
‘4’ is a member of set ‘{1,2,3,4}
What would you change to ‘12E{1,2,3,4}’ to show that 12 is not part of the set.
Put a horizontal line through the E-like shape
What does ∅ signify?
An empty set or a null set.
What is U?
The universal set
{1,2,3,4,5} = {3,2,4,1,5}
Is this correct?
Yes, they both equal each other despite the differing order.
{1,2,3,4,5} = {1,2,3,3,4,2,1,5}
Is this correct?
Yes, because within sets duplicates are not important.
{1,2,3,4} = {1,2,3,4,5}
Is this correct?
No, for they do not contain the same elements.
S = {2,3,4,5} T = {1,2,3,4,5,6}
Which, if any, is the subset?
S is the subset as all of its elements are contained with T.
What does an underline ‘c’ symbol indicate?
For example, XcV?
It indicates that the first set is a subset of the second set.
X is a subset of V.
How would you indicate that X is not a subset of V?
XcV with ‘c’ being underlined and a horizontal line going though it.
S = {1,2,3} T = {1,2,3,4}
Is S a subset or also a proper subset of T?
S is a proper subset of T because it does not equal itself.
Can S be a subset of S?
Yes, all sets can subsets of themselves.
What is the powerset of B = {1,2}?
P(B) = { {}, {1}, {2}, {1,2} }
What is the powerset of C = {1,2,3}
P(C) = { {}, {1}, {2}, {3}, {1,2}, {2,3}, {1,3}, {1,2,3} }
What is the powerset of D = {Coleraine, Belfast}
P(D) = { {}, {Coleraine}, {Belfast}, {Coleraine, Belfast} }
What does |A| mean?
The cardinality of A ie the number of elements in set A.
What is the cardinality of A = {1,2,3,4,5}
|A| = 5
What is the cardinality of S = { ∅, {A}, {B}, {A,B} }?
|S| = 4
{1,2,3}U{3,4,5} = ?
{1,2,3,4,5}
{1,2}U∅ = ?
{1,2}
{1,2,3}n{3,4,5} = ?
{3}
{1,2}n∅ = ?
∅
What is a disjoint set?
Disjoint sets have no elements in common.
{1,2,3} - {3,4,5} = ?
{1,2}
What does (AUB)’ mean?
’ means complement.
This means that everything that not within the A and B union.
What is the difference between a set and a multiset?
In a set, duplicates are not allowed.
In a multiset, duplicates are allowed.
Is {1,2,3,4,4} a set or a multiset?
A multiset because it has duplicates.
{a,a,a,b,b,c,c,d,d,d}
What is the multiplicity of a?
3
{a,a,a,b,b,c,c,d,d,d}
What is the multiplicity of d?
3
{a,a,a,b,b,c,c,d,d,d}
What is the cardinality of the above multiset?
10
{1,3,6,1,3,1}U{1,7,6,1,3,6} = ?
{1,1,1,3,3,6,6,7}
Only the max number of values from the multiset containing the most is taken.
{1,3,6,1,3,1}n{1,7,6,1,3,6} = ?
{1,1,3,6}
Only the min number of values is taken from each multiset where each multiset has the same value.
In an array 0-4, values with a set are ? when
false, true, true, false, true
{1,2,4}
How could you represent this multiset in an array 0-9?
{2,4,7,2,4,2,4,6,6}
{0,0,3,0,3,0,2,1,0,0}