Files
G4G0-2/Data Structures/Week 1/Workshop 1 - Mathematics Background.md
2024-10-16 09:12:37 +01:00

67 lines
1.5 KiB
Markdown

# 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`, where `a` is an element of the set `S`.
- Elements that are not contained are denoted as `d ∉ S`, where `d` is not an element of the set `S`.
## #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}
- 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
1. {b, h, r, q} $\subseteq$ {h, r} - True
2. {a, 13, d, 2} $\subseteq$ {13, 2, d, a} - True