1.5 KiB
1.5 KiB
Lists
- Ordered
- Denoted by (a1, a2, … an) or {a1, a2, …an}
Strings and Queues
Strings
- Ordered list
- (1,2,3,4) or {1,2,3,4}
Queue
- Special list, where elements are removed from the bottom, and added to the top.
Sets, Elements
- Any collection of objects is a set
- Objects contained in a set are elements, or members
- Set defined with braces.
- Conventional to use singular capital letters for names of sets.
- Commonly denoted a
a ∈ S
, wherea
is an element of the setS
.- Elements that are not contained are denoted as
d ∉ S
, whered
is not an element of the setS
.
- Elements that are not contained are denoted as
#Cardinality
- Cardinality of a set is the number of elements contained in the set.
- For example, let S = {a,b,c}, the cardinality of S is 3.
- These facts are denoted symbolically
- n(S) = 3.
Set Equality
- Two sets are equal if they contain exactly the same elements.
#Subsets
- Suppose V is a set, and W is a set formed using only elements of V.
- W would be a subset of V
- Denoted as
W ⊆ V
, where W is the subset of V - Every set is a subset of itself.
- {Moe, Larry}
\subseteq
{Moe, Larry}
- {Moe, Larry}
- The empty set is a subset of every set .
- {}
\subseteq
{Moe, Larry}
- {}
Example
Let T = {Moe, Larry, Curly}
List all subsets of T.
{Moe} {Larry} {Curly} {Moe, Larry} {Moe, Curly} {Larry, Curly} {Moe, Larry, Curly}
{} <- Empty Set
True or False
- {b, h, r, q}
\subseteq
{h, r} - True - {a, 13, d, 2}
\subseteq
{13, 2, d, a} - True