Revise the basics of the maths needed for working alongside with DSA.
•
•
•
•
•
•
•
•
•
• Floors:
[𝑥] is the largest integer not greater than x.
For 𝑥 ∈ ℝ, 𝑥 − 1 < [𝑥] ≤ 𝑥.
• Ceilings:
[𝑥] is the smallest integer not less than x.
For 𝑥 ∈ ℝ, 𝑥 ≤ [𝑥] < 𝑥 + 1.
• Properties:
𝑥 − 1 < [𝑥] ≤ 𝑥 ≤ [𝑥] ≤ 𝑥 + 1.
∀n ∈ Z, [n/2] + [n\2] = n.
∀a,b ∈ Z+, [a/b] ≤ (a + (b-1))/b.
• Example:
x | Floor | Ceiling |
---|---|---|
-1.1 | -2 | -1 |
0 | 0 | 0 |
1.01 | 1 | 2 |
2.9 | 2 | 3 |
3 | 3 | 3 |
The Arithmetic Sequence is a sequence of numbers such that the difference between successive terms in the sequence is constant.
• The first n values of the arithmetic sequence are:
• 𝑎, 𝑎 + 𝑑, 𝑎 + 2𝑑, 𝑎 + 3𝑑, ... , 𝑎 + (𝑛 − 1)𝑑.
• 𝑎 – initial value
• 𝑑 – difference
• Example: 1, 4, 7, 10, 13, 16, 19, ... (difference of 3).
The Arithmetic Series is the sum of the terms in the Arithmetic Sequence.
Let
$𝑎{_1} = 𝑎$ 𝑎𝑛d$a{_n} = 𝑎 + (𝑛 − 1)𝑑$
The Geometric Sequence is a sequence of numbers where each successive term is found by multiplying the previous term by a fixed, non-zero, common ratio.
• The first n values of the geometric sequence are:
• 𝑎, 𝑎𝑟, 𝑎𝑟2, 𝑎𝑟3, ... , 𝑎𝑟𝑛−1
• 𝑎 – initial value
• 𝑟 ≠ 0 – fixed multiplier
• Example: 1, 2, 4, 8, 16, 32, ... (common ratio of 2).
The Geometric Series is the sum of the terms in the Geometric Sequence.
When −1 < 𝑟 < 1, the sum of the in infinite geometric progression converges to:
• The first n values are: 1, 1 2 , 1 3 , ... , 1 𝑛
• The sum of these values can be represented with:
$$ \displaystyle\H{n}=\sum{i=0}^{n}(\frac{1}{i}) $$
• The harmonic series does not converge, but satisfies the following property:
ln(𝑛 + 1) < 𝐻𝑛 ≤ 1 + ln(𝑛)
A limit is a way of determining trends for values that may or may not exist
The definition of a limit follows such that if
Constants can be pulled out of limits when a ∈ ℝ and
The limit of a sum is the sum of the limits
The limit of a product is the product of the limits
The limit of a quotient is the quotient of the limits, when divisor is not 0 such that
Derivatives are a measure of how a function changes with respect to its input.
For a real-valued function of a single real variable, the derivative at a point is the slope of the tangent line to the graph of the function at that point.
• When
• $(f(x)g(x))$ = $((f(x))(g\
(x))) + ((f`(x))(g(x)))$
•
•
•
•
•
•
•
•
Assume 𝑓(𝑥) and 𝑔(𝑥) are both differentiable, with derivatives 𝑓′(𝑥) and 𝑔′(𝑥) respectively. Further, assume that 𝑐 ∈ ℝ.
A K-Permutation is an ordered subsequence of k distinct elements of a set S.
• The number of k-permutations of a set 𝑆, with |𝑆| = 𝑛 is:
n(n-1)(n-2)...(n-k+1) = n!/(n-k)!
• When S = {a,b,c}, the 2-permutations are {ab, ac, ba, bc, ca, cb}.
Example:
The number of 2-permutations of S(k=2) with |S| = n = 3 is: 3(3 − 1) = 3!/(3 − 2)! = 6/1 = 6.
A K-Combination is an un-ordered subsequence of k distinct elements of a set S
• The number of k-combinations of a set 𝑆, with |𝑆| = 𝑛 is:
n!/((n-k)!k!)
• When S = {a,b,c}, the 2-combinations are {ab, ac, bc}.
Example:
The number of 2-permutations of S(k=2) with |S| = n = 3 is: 3!/((3 − 2)!(2!)) = 6/2 = 3.
• We use the notation (𝑛/𝑘) (read: n choose k) to denote the number of k-combinations.
Properties:
•
•
•
•
• Binomial Coefficients can be used in binomial expansion. Binomial expansion is given by:
• In particular, when x = a = 1, we have: