This commit is contained in:
Boyan 2024-12-07 21:07:38 +01:00
parent 2fded76a5c
commit a9676272f2
120 changed files with 15925 additions and 1 deletions

View File

@ -0,0 +1,77 @@
---
date: 02.09.2024
type: theoretical
---
$\mathcal{O}$
## Complexity
- Time Complexity: amount of time an algorithm takes to complete as a function of the size of its input.
- Space Complexity: amount of memory it uses as a function of the size of its input.
### Big O
- **Formal Definition:**
Big O notation, $\mathcal{O}(f(n))$, describes the upper bound of the time or space complexity of an algorithm in terms of the input size $n$. It characterizes the worst-case scenario of an algorithm's growth rate.
Formally, a function $T(n)$ is said to be $\mathcal{O}(f(n))$ if there exist positive constants $c$ and $n_0$ such that for all $n \geq n_0$:
$$
0 \leq T(n) \leq c \cdot f(n).
$$
This means that $T(n)$ will grow at most as fast as $f(n)$, up to a constant multiple $c$, for sufficiently large $n$.
![Big O cheatsheet](Big%20o.png)
### Informally:
Big-O notation provides an upper limit on:
- **Time**: How long an algorithm will take.
- **Space**: How much memory it will require.
It helps compare algorithms by focusing on their growth rate and ignoring constant factors.
### Other Notations for Growth Rates
1. **Big-O ($\mathcal{O}(f(n))$)**:
- Describes the **upper bound** (worst-case) of $T(n)$.
- Informally: $T(n)$ grows no faster than $f(n)$.
- Formal Definition:
$$
T(n) \text{ is } \mathcal{O}(f(n)) \iff \exists c > 0, n_0 > 0 \text{ such that } T(n) \leq c \cdot f(n) \text{ for all } n \geq n_0.
$$
2. **Big-Omega ($\Omega(f(n))$)**:
- Describes the **lower bound** (best-case) of $T(n)$.
- Informally: $T(n)$ grows at least as fast as $f(n)$.
- Formal Definition:
$$
T(n) \text{ is } \Omega(f(n)) \iff \exists c > 0, n_0 > 0 \text{ such that } T(n) \geq c \cdot f(n) \text{ for all } n \geq n_0.
$$
3. **Big-Theta ($\Theta(f(n))$)**:
- Describes the **exact bound** (tight bound) of $T(n)$.
- Informally: $T(n)$ grows exactly as fast as $f(n)$.
- Formal Definition:
$$
T(n) \text{ is } \Theta(f(n)) \iff T(n) \text{ is } \mathcal{O}(f(n)) \text{ and } T(n) \text{ is } \Omega(f(n)).
$$
4. **Little-O ($o(f(n))$)**:
- Describes a **loose upper bound** of $T(n)$.
- Informally: $T(n)$ grows strictly slower than $f(n)$.
- Formal Definition:
$$
T(n) \text{ is } o(f(n)) \iff \forall c > 0, \exists n_0 > 0 \text{ such that } T(n) < c \cdot f(n) \text{ for all } n \geq n_0.
$$
Think of growth rates as vehicles on a highway:
- $\mathcal{O}(f(n))$: $T(n)$ cannot go faster than $f(n)$.
- $\Omega(f(n))$: $T(n)$ cannot go slower than $f(n)$.
- $\Theta(f(n))$: $T(n)$ moves at the exact same speed as $f(n)$.
- $o(f(n))$: $T(n)$ moves slower than $f(n)$ and never catches up.

View File

@ -0,0 +1,41 @@
---
date: 09.09.2024
type: theoretical
---
Divide and Conquer is a powerful algorithmic paradigm used to solve complex problems by breaking them down into smaller, more manageable sub-problems.
## Steps in Divide and Conquer
1. **Divide:**
- The problem is divided into smaller subproblems that are similar to the original but smaller in size.
- This division continues until the subproblems become simple enough to be solved directly.
2. **Conquer:**
- Solve the smaller subproblems recursively. If the subproblems are small enough (base cases), solve them directly without further recursion.
3. **Combine:**
- Combine the solutions of the subproblems to get the solution to the original problem.
### Example: Merge Sort
**Merge Sort** is a classic example of the Divide and Conquer approach:
1. **Divide:**
- Split the unsorted array into two halves recursively until each subarray contains a single element.
2. **Conquer:**
- Merge two sorted halves by comparing elements from each half in sorted order.
3. **Combine:**
- Combine the sorted halves to form a single sorted array.
The time complexity of Merge Sort is $\mathcal{O}(n \log n)$ because the array is repeatedly divided in half ($\log n$ divisions) and each division requires a linear amount of work ($\mathcal{O}(n)$) to merge.
### Other Examples
- **Quick Sort:** Uses Divide and Conquer by selecting a "pivot" element and partitioning the array into elements less than and greater than the pivot.
- **Binary Search:** Recursively divides a sorted array in half to search for an element, reducing the search space by half each time.
- **Strassen's Matrix Multiplication:** An algorithm that reduces the time complexity of matrix multiplication from $\mathcal{O}(n^3)$ to approximately $\mathcal{O}(n^{2.81})$ by recursively breaking down matrices.

View File

@ -0,0 +1,139 @@
---
date: 11.09.2024
type: theoretical
---
**travelling salesperson**
## Definition
- Approach to design algorithms
- Optimal solution in polynomial time
- Usually used alongside [Divide and Conquer](Divide%20and%20Conquer.md)
- Used to better the time [complexity](Complexity.md), but usually worsens the space complexity
### How do we create a DP soluton?
- Characterize optimal solution
- Recursively define the value of an optimal solution
- Compute the value
- Construct an optimal solution **from the computed information**
## Problem discussion
### Calculating Fibonacci numbers
- Recursion is extremely bad -> PF was wrong
- Because the branches are too many
- We compute f(x) where f(x) has already been computed
- Memoization!
#### Approaches
- Linear time $\mathcal{O}(n)$ - **Bottom to top**
```pseudo
F[0] = 1
F[1] = 1
for i in {2, .., n} do
F[i] = F[i 1] + F[i 2]
end for
return F[n]
```
Compute the entire array and just return the result.
- Memoization $\mathcal{O}(n)$ - **Top to bottom**
```javascript
function fibMemo(index, cache) {
cache = cache || [];
if (cache[index]) return cache[index];
else {
if (index < 3) return 1;
else {
cache[index] = fibMemo(index - 1, cache) + fibMemo(index - 2, cache);
}
}
return cache[index];
}
```
### [Rod cutting](https://www.geeksforgeeks.org/problems/rod-cutting0840/1)
Given a rod of length N inches and an array of prices, price[]. price[i] denotes the value of a piece of length i. Determine the maximum value obtainable by cutting up the rod and selling the pieces.
#### Optimal solution
- Let the left part have a length $l$
- Then $R[n] = P[l] + R[n-l]$
- Where $P[l]$ is the price
- First cut of length should be the maximal one
### Knight Collecting Rewards
>Knight Collecting rewards
Input: Integers $n, m$, table of rewards of size $n \times m$
Question: What is the maximum reward that the knight can get for its journey.
#### Strategy
- We look at the bounds defined by the problem statement
- We know that the knight can get into the cell $(n-1, m-1)$ either from $(n-2,m-3)$ or $(n-3,m-2)$
- Hence, we have to know the most rewarding path to these two points from $(0,0)$
#### Approaches
- $\mathcal{O}(n*m)$
```
Reward(int n, int m, matrix A)
Create matrix R of size n × m with −∞ values
R[0, 0] = A[0, 0]
for i in {0, .., n 1} do
for j in {0, .., m 1} do
R[i, j] = A[i, j] + max R[i 1, j 2], R[i 2, j 1]
end for
end for
return R[n-1, m-1]
```
This doesn't tell us how we got there, but it does give us max rewards.
We can easily include path memory by making elements be a linked list or create a separate table blah blah.
### [Longest common non-contiguous sequence](https://www.geeksforgeeks.org/longest-common-subsequence-dp-4/)[^1]
> LCS
Input: Two sequences X = [x1, x2, . . . xm], Y = [y1, y2, . . . , Yn].
Question: Longest common subsequence
#### Strategy
![[LCS.png]]
Or this formula:
$$
c[i,j] = \begin{cases}
0, & \text{if } i=0 \text{ or } j=0\\
c[i-1,j-1]+1, & \text{if } i,j>0 \text{ and } x_i = y_i\\
max\{c[i,j-1], c[i-1], j\}, & \text{if } i,j>0 \text{ and } x_i \neq y_i\\
\end{cases}
$$
### [Dominating set](https://www.geeksforgeeks.org/dominant-set-of-a-graph/)[^2] in a path
>Input: A path $P$ with a specified positive cost for each vertex.
Output: Choose a subset of vertices $S$ with a minimum cost such that for each $v \in P$: either $v \in S$ or there is u such that $u \in S$ and $u, v$ are neighbors.
#### Strategy
- Identify some subproblems
- $A[i]$ cost of the cheapest set $S_i \subset P_i$ which dominates all vertices in $P_i$ <- not great
- $A[i,0]$ equals the cost of the cheapest $S_i$ which dominates $P_i$ and $v_i \notin S_i$
- $A[i,1]$ equals the cost of the cheapest
[^1]: **contiguous** - next or near in time or sequence
[^2]: [Subset of the vertices of the graph $G$, such that any vertex of $G$ is in it, or has a neighbor in it](https://en.wikipedia.org/wiki/Dominating_set)

View File

@ -0,0 +1,157 @@
---
type: theoretical
---
Can be utilized in algorithms. Here's a rundown of a couple of popular graph algorithms along with their use case and [Complexity](Complexity.md). TSP is [NP](P%20vs.%20NP.md), but it can be approximated/solved using a graph algorithm!
![](graph-algorithms-infographic.gif)
# Graph Algorithms
## Shortest Path Algorithms
### Dijkstra's Algorithm
Finds the shortest path from a source vertex to all other vertices in a graph with non-negative edge weights.
1. Initialize distances:
- Set the distance to the source vertex as 0 and all others as infinity.
2. Use a priority queue (min-heap) to extract the vertex with the smallest distance.
3. For each neighboring vertex, calculate the tentative distance via the current vertex:
- If the tentative distance is smaller than the known distance, update it.
4. Repeat until all vertices are processed.
- Using a priority queue: $O((V + E) \log V)$, where $V$ is the number of vertices and $E$ is the number of edges.
![](Dijkstra01.gif)
### Floyd-Warshall Algorithm
Computes shortest paths between all pairs of nodes in a weighted graph.
1. Initialize distances with edge weights.
2. Iteratively update distances by considering each node as an intermediate point.
3. Handle both positive and negative edge weights (no negative cycles allowed).
- **Complexity**: $O(V^3)$, where $V$ is the number of vertices.
![Floyd-Warshall Algorithm](218610439-933d939c-a9e1-489d-a0a2-da8cf7bf51c1.gif)
---
## Minimum Spanning Tree Algorithms
### Kruskal's Algorithm
Finds the minimum spanning tree (MST) of a graph.
1. Sort all edges by weight.
2. Add edges to the MST in increasing order of weight.
3. Skip edges that form a cycle (using Union-Find data structure :) ).
- **Complexity**: $O(E \log E)$, where $E$ is the number of edges.
![](Animation%20of%20Kruskal's%20Algorithm.gif)
### Prim's Algorithm
Constructs the minimum spanning tree (MST) of a graph.
1. Start with an arbitrary node.
2. Repeatedly add the smallest edge that connects a node in the MST to a node outside it.
3. Continue until all nodes are included.
- $O(E + V \log V)$ using a priority queue, where $V$ is the number of vertices and $E$ is the number of edges.
![Prim's Algorithm](4e486f5e-8437-4e2b-8964-5d5860208502_1650942396.093046.gif)
---
## Graph Traversal Algorithms
### Depth-First Search (DFS)
Explores as far as possible along each branch before backtracking.
- Detects cycles.
- Topological sorting.
- Pathfinding in mazes.
- **Complexity**: $O(V + E)$.
![](1_WR4AtjT_nhwSOtAW99Yd5g.gif)
---
### Breadth-First Search (BFS)
explores all neighbors at the current depth before moving to the next level.
- Finding shortest paths in unweighted graphs.
- Level-order traversal of trees.
- **Complexity**: $O(V + E)$.
![](bfs.gif)
![](dfs-vs-bfs.gif)
---
## Topological Sorting
Arranges the vertices of a directed acyclic graph (DAG) in a linear order such that for every directed edge $(u, v)$, $u$ comes before $v$.
- Perform a DFS and use a stack to store the vertices in reverse order of completion.
- **Complexity**: $O(V + E)$.
![](anim.gif)
---
## Maximum Flow Algorithms
### Ford-Fulkerson Algorithm
**Finds the maximum flow in a flow network.
1. Initialize the flow to 0.
2. While there is an augmenting path, increase the flow along the path.
3. Repeat until no augmenting paths remain.
- **Complexity**: $O(E \cdot \text{max\_flow})$.
![](FordFulkerson.gif)
---
### Edmonds-Karp Algorithm
A refinement of the Ford-Fulkerson algorithm that uses BFS to find augmenting paths.
- **Complexity**: $O(V \cdot E^2)$.
![](56e7f380-cd33-11eb-90b2-658e8d102a95.gif)
---
## Grid-Based Algorithms
### A* Algorithm
Finds the shortest path in a weighted grid using a heuristic.
1. Start from the source node.
2. Use a priority queue to explore the most promising paths first.
3. Use a heuristic to guide the search toward the goal.
- **Complexity**: Depends on the heuristic but generally better than BFS for weighted grids.
![](A.gif)
---
## Graph Coloring
Assigns colors to vertices such that no two adjacent vertices share the same color.
- **Algorithms**:
- Greedy coloring: $O(V^2)$.
- Backtracking for exact coloring.
---

View File

@ -0,0 +1,98 @@
---
type: mixed
---
## Definition of a Graph
A data structure that consists of:
- A set of vertices (or nodes).
- A set of edges, which connect pairs of vertices.
### Types of Graphs
1. **Directed Graph**:
- Edges have a direction, going from one vertex to another.
- Example: Websites linked via hyperlinks.
2. **Undirected Graph**:
- Edges have no direction; they simply connect two vertices.
- Example: Social networks where a connection is mutual.
3. **Weighted Graph**:
- Each edge is assigned a weight or cost.
- Example: Road networks where edge weights represent distances.
## Binary Tree
A hierarchical data structure where each node has at most two children, referred to as the left and right child. This structure is foundational for tasks such as expression parsing and hierarchical data representation.
- Maximum of two children per node.
- Recursive structure: subtrees are binary trees themselves.
![](Pasted%20image%2020241203231354.png)
---
## Binary Search Tree (BST)
A Binary Search Tree is a binary tree that maintains sorted order:
- For any node:
- All values in the left subtree are smaller.
- All values in the right subtree are larger.
- Enables $O(\log n)$ search, insertion, and deletion.
![](binary-search-tree-sorted-array-animation.gif)
---
## Balanced Tree (AVL Tree)
A self-balancing binary search tree where:
- The balance factor (difference in heights of left and right subtrees) of any node is at most one.
- Rotations are used to maintain balance during insertions and deletions.
- Guaranteed $O(\log n)$ operations.
- Ensures balanced growth for fast access.
![](YieLsCqeuV-avlbal.gif)
---
## Grids as Graphs
Can be modeled as a graph:
- Vertices: Represent grid cells.
- Edges: Represent valid movements between cells (e.g., up, down, left, right).
![](Pasted%20image%2020241203231638.png)
---
## Famous Graph Problems
Solved using [Graph Algorithms](Graph%20Algorithms.md).
### Shortest Path Problems
- Find the minimum distance or cost to travel between two nodes.
- **We can use**:
- Dijkstra's Algorithm (if non-negative weights).
- Bellman-Ford Algorithm (handles negative weights).
- Floyd-Warshall Algorithm (if we want all-pairs shortest paths).
### Minimum Spanning Tree (MST)
- Find a subset of edges that connects all vertices with the minimum total weight.
- **We can use**:
- Kruskal's Algorithm.
- Prim's Algorithm.
### Topological Sorting
- Arrange the vertices of a DAG in linear order such that for every directed edge $(u, v)$, $u$ appears before $v$.
### Max Flow / Min Cut
- Find the maximum flow possible in a network from a source to a sink.
- Ford-Fulkerson Algorithm.
- Edmonds-Karp Algorithm.
### Traveling Salesman Problem (TSP)
- Find the shortest tour that visits each vertex exactly once and returns to the starting point.
### Pathfinding in Grids
- Find the shortest path in a grid-based graph.
- **We can use**:
- A* Algorithm (heuristic-based).
- Breadth-First Search (BFS) for unweighted grids.
---

View File

@ -0,0 +1,82 @@
---
type: theoretical
---
![Video](https://www.youtube.com/watch?v=mdQzAp7gSns)
![Video 2](https://youtu.be/pQsdygaYcE4)
## Definition
- Class P
- The set of decision problems that can be solved by a deterministic Turing machine in polynomial time[^1]. These are problems considered to be efficiently solvable.
- $O(\log n)$
- The set of decision problems for which a given solution can be verified in polynomial time by a deterministic Turing machine[^2]. NP stands for "nondeterministic polynomial time."
- :LiLoaderPinwheel: Does $\mathbf{P = NP}$?
- This is one of the most important open questions in computer science. It asks whether every problem whose solution can be quickly verified can also be quickly solved.
## Understanding P and NP
![](Pasted%20image%2020241203234032.png)
### Class P Problems
- Solvable in polynomial time.
- Algorithms exist that can find a solution efficiently as the input size grows.
- **As seen in**:
- Prime Testing: Determining if a number is prime.
- Shortest Path: Finding the shortest path in a graph (e.g., Dijkstra's algorithm).
- Sorting Algorithms: Such as Quick Sort and Merge Sort.
### Class NP Problems
- Solutions can be verified in polynomial time.
- No known polynomial-time algorithms to solve all NP problems.
- **As in**:
- Subset Sum: Determining if a subset of a given set of integers sums up to a target integer.
- 3-SAT: Determining if a Boolean formula in conjunctive normal form with at most three literals per clause is satisfiable.
- Hamiltonian Cycle: Determining if a Hamiltonian cycle exists in a graph.
## NP-Complete Problems
- The hardest problems in NP. A problem is NP-Complete if:
- It is in NP.
- Every problem in NP can be reduced to it in polynomial time[^3].
- Implications: If any NP-Complete problem is solvable in polynomial time, then $P = NP$.
- Traveling Salesperson Problem (Decision Version): Determining if there's a tour shorter than a given length.
- Clique Problem: Finding a complete subgraph (clique) of a certain size in a graph.
- Vertex Cover: Determining if there exists a set of vertices covering all edges.
## Problems
### Subset Sum Problem
- **Input**: A set of integers and a target sum.
- **Question**: Is there a subset whose sum equals the target?
- **Approach**:
- **Exponential Time**: Checking all possible subsets.
- **Dynamic Programming**: Pseudo-polynomial time algorithm when numbers are small.
### 3-SAT Problem
- **Input**: A Boolean formula in 3-CNF (Conjunctive Normal Form).
- **Question**: Is there a truth assignment that satisfies the formula?
- **Importance**: The first problem proven to be NP-Complete (Cook-Levin theorem).
## Strategies
- Find solutions close to optimal in polynomial time.
- Practical methods that find good-enough solutions without guaranteeing optimality (heuristics).
- Restricting the problem to a subset where it becomes solvable in polynomial time.
## NP vs. NP-Complete Differences
|**Aspect**|**NP**|**NP-Complete**|
|---|---|---|
|**Definition**|Problems whose solutions can be verified quickly.|Hardest problems in NP. All NP problems reduce to them.|
|**Relation to P**|Contains P (P ⊆ NP).|If any NP-complete problem is in P, P = NP.|
|**Ease of Solution**|Some problems may have unknown solution methods.|Believed to be computationally difficult to solve.|
|**Examples**|Subset Sum, 3-SAT|TSP, Clique, Vertex Cover|
![](Pasted%20image%2020241203234600.png)
[^1]: a theoretical computing machine that uses a predetermined set of rules to determine its actions.
[^2]: a theoretical model that, unlike a deterministic Turing machine, can make "guesses" to find solutions more efficiently.
[^3]: a method of converting one problem to another in polynomial time, preserving the problem's computational complexity.
[^4]: the complements of NP-Complete problems, where verifying a "no" instance is in NP.

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1,86 @@
---
type: mixed
---
## Prefix Function ($\pi$)
The prefix function is a tool used in pattern matching algorithms, particularly in the **Knuth-Morris-Pratt (KMP) algorithm**. It is designed to preprocess a pattern to facilitate efficient searching.
### Definition
For a string $P$ of length $m$, the prefix function $\pi[i]$ for $i = 1, 2, \ldots, m$ is the length of the longest proper prefix of the substring $P[1 \ldots i]$ that is also a suffix of this substring.
### Key Points
1. A proper prefix of a string is a prefix that is not equal to the entire string. [^1]
2. $\pi[i]$ helps skip unnecessary comparisons in pattern matching by indicating the next position to check after a mismatch.
3. $\pi[1] = 0$ always, since no proper prefix of a single character can also be a suffix.
### Example
For the pattern $P = "ababcab"$:
- $P[1] = "a"$: $\pi[1] = 0$.
- $P[1 \ldots 2] = "ab"$: No prefix matches the suffix, so $\pi[2] = 0$.
- $P[1 \ldots 3] = "aba"$: Prefix "a" matches suffix "a", so $\pi[3] = 1$.
- $P[1 \ldots 4] = "abab"$: Prefix "ab" matches suffix "ab", so $\pi[4] = 2$.
- Continue similarly to compute $\pi[i]$ for the entire pattern.
---
## Knuth-Morris-Pratt (KMP) Algorithm
The KMP algorithm is a pattern matching algorithm that uses the prefix function $\pi$ to efficiently search for occurrences of a pattern $P$ in a text $T$.
### Key Idea
When a mismatch occurs during the comparison of $P$ with $T$, use the prefix function $\pi$ to determine the next position in $P$ to continue matching, rather than restarting from the beginning.
### Steps
1. Compute the prefix function $\pi$ for the pattern $P$.
2. Search:
- Compare $P$ with substrings of $T$.
- If theres a mismatch at $P[j]$ and $T[i]$, use $\pi[j]$ to shift $P$ rather than restarting at $P[1]$.
3. The algorithm runs in $O(n + m)$ time [complexity](Complexity.md), where $n$ is the length of $T$ and $m$ is the length of $P$.
---
## Rabin-Karp Algorithm
The Rabin-Karp algorithm is another pattern matching algorithm, notable for using hashing to identify potential matches.
### Key Idea
Instead of comparing substrings character by character, the algorithm compares hash values of the pattern and substrings of the text.
### Steps
1. Compute the hash value of the pattern $P$ and the first substring of the text $T$ of length $m$.
2. Slide the window over $T$ and compute hash values for the next substrings in constant time using a rolling hash. [^2]
3. If the hash value of a substring matches the hash value of $P$, compare the actual strings to confirm the match.
### Hash Function
The hash function is typically chosen such that it is fast to compute and minimizes collisions:
$$
h(s) = (s[1] \cdot p^{m-1} + s[2] \cdot p^{m-2} + \ldots + s[m] \cdot p^0) \mod q,
$$
where:
- $p$ is a base (e.g., a small prime number),
- $q$ is a large prime to avoid overflow.
### Complexity
- Best Case: $O(n + m)$, where $n$ is the length of the text and $m$ is the length of the pattern.
- Worst Case: $O(nm)$ due to hash collisions.
---
## KMP v.s. Rabin-Karp
| Feature | Knuth-Morris-Pratt (KMP) | Rabin-Karp |
| ------------- | ------------------------ | --------------------------------------------------- |
| Technique | Prefix function | Hashing |
| Preprocessing | Compute $\pi$ array | Compute hash of $P$ |
| Efficiency | $O(n + m)$ | $O(n + m)$ (best), $O(nm)$ (worst) |
| Use Case | Best for exact matches | Useful for multiple patterns or approximate matches |
| | | |
_This graphic is too AI generated for me_ -> Use KMP when looking for a pattern, use RK when multiple patterns
---
## Footnotes
[^1]: A proper prefix of a string $s$ is any prefix of $s$ that is not equal to $s$ itself. For example, proper prefixes of "abc" are "", "a", and "ab".
[^2]: A rolling hash computes the hash of a new substring by updating the hash of the previous substring, avoiding the need to recompute from scratch.

View File

@ -0,0 +1,126 @@
---
type: mixed
---
In algorithmics, a **recurrence relation** is often used to describe the time complexity of recursive algorithms. It expresses how the running time of an algorithm depends on the size of the input and the cost of recursive calls.
- **Example**: Consider the merge sort algorithm, which divides the input of size $n$ into two halves, recursively sorts each half, and then merges the two sorted halves. Its recurrence relation is:
$$
T(n) = 2T\left(\frac{n}{2}\right) + O(n),
$$
where:
- $2T\left(\frac{n}{2}\right)$ represents the two recursive calls on halves of the input.
- $O(n)$ represents the time to merge the two halves.
---
## Solving Recurrence Relations for Time Complexity
To determine the time complexity of an algorithm, we solve the recurrence relation to find an explicit formula for $T(n)$.
### 1. **Backtracking**
This involves repeatedly substituting the recurrence relation into itself until a pattern emerges.
- **Example**: For the recurrence $T(n) = 2T\left(\frac{n}{2}\right) + O(n)$:
- First substitution:
$$
T(n) = 2\left[2T\left(\frac{n}{4}\right) + O\left(\frac{n}{2}\right)\right] + O(n)
= 4T\left(\frac{n}{4}\right) + 2O\left(\frac{n}{2}\right) + O(n).
$$
- Second substitution:
$$
T(n) = 8T\left(\frac{n}{8}\right) + 4O\left(\frac{n}{4}\right) + 2O\left(\frac{n}{2}\right) + O(n).
$$
- General pattern:
$$
T(n) = 2^k T\left(\frac{n}{2^k}\right) + O\left(n \log n\right).
$$
- When $k = \log n$, the base case $T(1)$ is reached, so:
$$
T(n) = O(n \log n).
$$
---
### 2. **Master Theorem**
The **Master Theorem** provides a direct way to analyze recurrence relations of the form:
$$
T(n) = aT\left(\frac{n}{b}\right) + O(n^d),
$$
where:
- $a$ is the number of recursive calls,
- $b$ is the factor by which the input size is divided,
- $d$ is the exponent of the non-recursive work. [^1]
The solution depends on the comparison of $a$ with $b^d$:
1. **Case 1 ($a < b^d$)**: The work outside recursion dominates.
$$
T(n) = O(n^d).
$$
2. **Case 2 ($a = b^d$)**: The work is evenly distributed.
$$
T(n) = O(n^d \log n).
$$
3. **Case 3 ($a > b^d$)**: The recursion dominates.
$$
T(n) = O(n^{\log_b a}).
$$
- **Example**: For $T(n) = 2T\left(\frac{n}{2}\right) + O(n)$:
- $a = 2$, $b = 2$, $d = 1$.
- Compare $a$ with $b^d$: $2 = 2^1$, so it falls under **Case 2**.
- Solution:
$$
T(n) = O(n \log n).
$$
---
### 3. **Substitution Method**
This involves guessing a solution and proving it correct using **mathematical induction**.
- **Example**: For $T(n) = 2T\left(\frac{n}{2}\right) + O(n)$, guess $T(n) = O(n \log n)$:
1. Assume $T(k) = O(k \log k)$ for $k < n$ (inductive hypothesis).
2. Substitute into the recurrence:
$$
T(n) = 2T\left(\frac{n}{2}\right) + O(n).
$$
Using the hypothesis:
$$
T\left(\frac{n}{2}\right) = O\left(\frac{n}{2} \log \frac{n}{2}\right) = O\left(\frac{n}{2} (\log n - 1)\right).
$$
Simplify:
$$
T(n) = 2 \cdot O\left(\frac{n}{2} \log n\right) + O(n) = O(n \log n).
$$
3. Conclusion: The guess is correct.
---
## Applications in Algorithm Design
1. **Divide and Conquer**: Many divide-and-conquer algorithms, like merge sort, quicksort, and binary search, have their time complexity described by recurrence relations.
2. **Dynamic Programming**: Recurrences are also used to describe subproblem dependencies in dynamic programming algorithms.
3. **Graph Algorithms**: Recurrences appear in graph traversal techniques and optimization algorithms (e.g., shortest paths).
---
## Tips for Mastering Recurrence Relations
1. Understand the **nature of recursion** in the algorithm (e.g., how input is divided, base cases, etc.).
2. Identify the **dominant term** in the recurrence to estimate growth.
3. Use tools like **backtracking**, the **Master Theorem**, or **substitution** to solve recurrences efficiently.
4. Practice interpreting recurrences in terms of algorithm behavior.
---
### Backlinks
- [Recurrence relations](Discrete%20Structures/Recurrence%20relations.md)
- [Complexity](Complexity.md)
[^1]: The Master Theorem simplifies solving divide-and-conquer recurrences by comparing the relative growth of recursion and non-recursive work.

View File

@ -0,0 +1,39 @@
---
date: 02.09.2024
type: mixed
---
## Sorting algorithms and their [complexity](Complexity.md)
| **Algorithm** | **Time Complexity** |
| ------------- | ------------------------------------------------------------- |
| Selection | $\mathcal{O}(n^2)$ |
| Insertion | $\mathcal{O}(n^2)$ |
| Bubble | $\mathcal{O}(n^2)$ |
| Quick | $\mathcal{O}(n^2)$ worst case, $\mathcal{O}(n\log n)$ average |
| Merge | $\mathcal{O}(n\log n)$ |
| Heap | $\mathcal{O}(n\log n)$ |
### Selection Sort
![Selection sort](Selection-sort-0.png)
![](selection_sort.gif)
### Insertion sort
![](insertion_sort.gif)
### Bubble sort
![](bubble_sort.gif)
### Quick sort
![](quick_sort.gif)
### Merge sort
![](merge_sort.gif)
Cooler visual:
![](Merge-sort.gif)
### Heap sort
![](Heap_sort.gif)

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,478 @@
---
excalidraw-plugin: parsed
tags:
- excalidraw
type: mixed
---
==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'
# Code Block
The code provided is an implementation designed to solve the *Volcano Research* problem efficiently using an AVL tree data structure. Heres a step-by-step explanation of how the code works and how it solves the problem:
### Problem Recap
Martin and Szymon want to know which species live at specific distances from a volcano based on given queries. The solution needs to determine which species are present at a given distance and then provide the k-th species name from the alphabetically sorted list of species at that distance. If there are fewer species than `k` at that distance, the output should be `-`.
### High-Level Overview of the Solution
1. **Data Representation**:
- The code uses structures (`Species` and `Event`) to store the information about species and events.
- An AVL tree (a self-balancing binary search tree) is used to keep track of species that are currently within the queried distance range efficiently.
2. **Input Parsing and Initialization**:
- The input consists of species data (name and range) and queries (distance and index).
- The code reads the input and populates two arrays: one for species (`Species` array) and one for events (`Event` array).
3. **Event Generation**:
- The code generates three types of events for each species:
- `START` event: marks the beginning of the range where the species can be found.
- `END` event: marks the end of the range.
- `QUERY` event: represents each query (distance and k value).
- These events are stored in a list and sorted based on their distance and type to handle them in an ordered manner.
4. **Processing Events**:
- The code processes each event in order of distance and type (using the `compareEvents` function for sorting):
- **`START` Event**: The species becomes active at this distance, so it is added to the AVL tree.
- **`END` Event**: The species goes out of range, so it is removed from the AVL tree.
- **`QUERY` Event**: The code checks the AVL tree to see if there are enough species within the distance range to answer the query.
5. **AVL Tree Operations**:
- **Insertion and Deletion**: The AVL tree is updated when species start or end at certain distances. This keeps the tree balanced, ensuring efficient lookups.
- **Finding the k-th Species**: When a query is processed, the code checks the size of the tree (`getSize`) to see if there are at least `k` species available. If so, it finds the k-th species using an in-order traversal (`findKth`).
6. **Output Generation**:
- The code collects the results for each query and outputs the appropriate species name if found, or `-` if fewer than `k` species are present.
### Detailed Explanation of the Code
1. **Data Structures**:
- `Species` Structure: Contains the name, start, and end distances, and a unique ID (`speciesId`) for each species.
- `Event` Structure: Represents different events (START, END, QUERY) with associated data like distance, species ID, and query parameters.
2. **Sorting Species by Name**:
- The `speciesPtrs` array is used to sort species alphabetically. Each species is assigned an ID based on this sorted order, which will help in quickly finding and outputting species names in alphabetical order.
3. **Events Sorting**:
- The events are sorted first by distance and then by type (`START`, `QUERY`, `END`), ensuring that they are processed in the correct order for efficient tree management.
4. **AVL Tree Functions**:
- The code uses several AVL tree functions to manage the tree:
- `insert` adds a species ID to the tree.
- `erase` removes a species ID when the species goes out of range.
- `findKth` finds the k-th smallest element in the tree, which corresponds to the species alphabetically.
- `getSize` returns the current number of species in the tree.
5. **Efficient Query Handling**:
- As events are processed in sorted order, the AVL tree always contains only the species that are active at the current distance, ensuring that queries are handled efficiently without scanning the entire dataset.
6. **Final Output**:
- The `answers` array collects the results for each query. The code uses the species ID from the AVL tree to look up the species name using the `speciesPtrs` array and prints it. If there are fewer species than `k` at the queried distance, it outputs a `-`.
### Why This Approach Works Efficiently
- **Event-based Approach**: By treating species ranges and queries as events, the solution efficiently processes the data in a linear sweep, avoiding unnecessary iterations over all distances.
- **AVL Tree**: The self-balancing nature of the AVL tree ensures that insertion, deletion, and k-th smallest element retrieval are all efficient (O(log n)), keeping the solution within time limits even for the maximum input size.
- **Memory Management**: The code efficiently uses dynamic memory to handle the large constraints of up to 300,000 species and queries.
### Complexity Analysis
- **Time Complexity**: Sorting events takes \(O(m \log m)\), where \(m = 2n + q\). AVL tree operations (insert, delete, and findKth) all take \(O(\log n)\), ensuring that the solution runs efficiently within the constraints.
- **Space Complexity**: The memory usage is primarily dominated by storing species, events, and the AVL tree nodes, which is handled efficiently within the provided memory limit.
In summary, the code uses an event-driven approach combined with an AVL tree to maintain a dynamic set of species efficiently, allowing for quick lookups and updates to answer the queries in the required time and space constraints.
# Code Block 1
An AVL tree is a self-balancing binary search tree (BST), named after its inventors Adelson-Velsky and Landis. The AVL tree maintains its height to ensure that all operations (insertion, deletion, lookup, etc.) are performed in \( O(\log n) \) time. This efficiency is achieved by maintaining a balance factor at each node and rebalancing the tree when necessary. Let's go through the details step by step, including augmentation.
### 1. Structure of an AVL Tree
An AVL tree is a binary search tree where each node contains:
- **Value/Key**: The value stored in the node.
- **Left and Right Pointers**: Pointers to the left and right child nodes.
- **Height**: The height of the node (i.e., the number of edges on the longest path from the node to a leaf).
- **Balance Factor**: The balance factor is the difference in height between the left and right subtrees of the node:
\[
\text{Balance Factor} = \text{Height of Left Subtree} - \text{Height of Right Subtree}
\]
An AVL tree ensures that the balance factor of every node is either \(-1\), \(0\), or \(1\). If any node's balance factor falls outside this range, the tree is rebalanced to restore this property.
### 2. Operations in an AVL Tree
The main operations in an AVL tree are insertion, deletion, and lookup. Lets go through each:
#### a. Insertion
1. **Standard BST Insertion**: Insert the node like in a regular BST, placing it in its appropriate position based on the value.
2. **Update Heights**: Traverse back up the tree, updating the height of each node.
3. **Check and Fix Balance**: After updating heights, check the balance factor of each node. If it goes out of the range \([-1, 1]\), perform rotations to rebalance.
#### b. Rotations for Rebalancing
There are four types of rotations:
1. **Right Rotation (Single)**:
- Applied when the left subtree of a node becomes too tall.
- Rotate the subtree right, making the left child the new root of the subtree.
2. **Left Rotation (Single)**:
- Applied when the right subtree of a node becomes too tall.
- Rotate the subtree left, making the right child the new root of the subtree.
3. **Left-Right Rotation (Double)**:
- Applied when the left subtree's right subtree is too tall.
- Perform a left rotation on the left child, then a right rotation on the node.
4. **Right-Left Rotation (Double)**:
- Applied when the right subtree's left subtree is too tall.
- Perform a right rotation on the right child, then a left rotation on the node.
#### c. Deletion
1. **Standard BST Deletion**: Remove the node like in a standard BST (with handling for nodes having 0, 1, or 2 children).
2. **Update Heights**: Update the heights of the nodes as you traverse back up.
3. **Check and Fix Balance**: If the balance factor goes out of range, perform the appropriate rotations to restore balance.
#### d. Lookup/Search
Since the AVL tree is a balanced BST, lookup/search operations are similar to a regular BST and run in \( O(\log n) \) time.
### 3. AVL Tree Augmentation
Augmentation involves adding extra information or functionality to the AVL tree beyond just storing values and maintaining balance. This is useful for answering more complex queries efficiently. One common augmentation is adding the **size** of the subtree at each node.
#### Augmenting with Subtree Size
In the AVL tree, we augment each node with an additional field:
- **Size**: The number of nodes in the subtree rooted at this node.
The size field is updated during insertion, deletion, and rotations, just like the height. The size of a node is:
\[
\text{Size} = 1 + \text{Size of Left Subtree} + \text{Size of Right Subtree}
\]
This augmentation allows us to:
1. **Find the k-th smallest element** efficiently.
2. **Count the number of elements within a range**.
3. **Rank of an element** (position in the sorted order).
##### Finding the k-th Smallest Element
To find the k-th smallest element:
1. Compare \( k \) with the size of the left subtree (\( \text{Size of Left Subtree} + 1 \)).
- If \( k \) equals this value, the current node is the k-th smallest.
- If \( k \) is smaller, the k-th smallest element is in the left subtree.
- If \( k \) is larger, adjust \( k \) to \( k - (\text{Size of Left Subtree} + 1) \) and search in the right subtree.
This approach allows finding the k-th smallest element in \( O(\log n) \) time due to the balanced nature of the tree.
### 4. Example of an Augmented AVL Tree in Practice
Lets walk through an example of how the augmented AVL tree can be used to find the k-th smallest element:
#### Example Tree (Balanced AVL)
```
15 (5)
/ \
10 (3) 20 (1)
/ \
5 (1) 12 (1)
```
- Numbers in parentheses represent the size of the subtree rooted at that node.
- To find the 3rd smallest element:
1. Check the left subtree of the root (15). The size is 3.
2. Since \( k = 3 \), and the size of the left subtree plus one is also 3, the roots left child (10) is the answer.
#### Updates and Maintenance
- **Insertion**: When a node is added, the tree is rebalanced if necessary, and sizes are updated accordingly as the recursive call returns.
- **Deletion**: When a node is deleted, the size is also updated as you traverse back up, and rotations are applied if the tree becomes unbalanced.
### 5. Applications of AVL Trees and Their Augmentations
1. **Interval Trees**: AVL trees can be augmented to store intervals and efficiently answer queries like finding overlapping intervals.
2. **Order Statistics**: By keeping track of subtree sizes, AVL trees can efficiently find the rank or the k-th smallest/largest element.
3. **Range Queries**: Augmenting nodes with additional data (like sum or minimum/maximum) can help quickly answer range queries in \( O(\log n) \) time.
### 6. Summary
- **AVL Tree Basics**: Its a self-balancing binary search tree ensuring \( O(\log n) \) operations by maintaining balance factors and using rotations.
- **Augmentation**: Adding extra information (e.g., subtree size) enhances the functionality, allowing efficient solutions to complex problems like finding k-th smallest elements or performing range queries.
- **Efficiency**: The augmented AVL tree remains efficient in terms of both time and space, as each operation still runs in \( O(\log n) \) time, making it suitable for handling large data sets.
The use of AVL trees (with or without augmentation) is fundamental in many computational problems where dynamic updates and efficient queries are required, making them a versatile tool in computer science.
# Code Block 2
The provided code solves the *For the Greater Good* problem using a combination of sorting and a max-heap strategy. The code efficiently determines the maximum number of generators that Bob can hack while alternating between AC and DC generators. Let's go through the code step by step to understand how it works.
### Problem Recap
Bob needs to hack as many generators as possible, alternating between AC and DC generators. He starts with a certain amount of experience points (`XP`), and each generator has:
- **Type** (`0` for AC, `1` for DC)
- **XP Needed**: The minimum XP required to hack the generator
- **XP Generated**: The amount of XP Bob gains after hacking that generator.
Bob can hack a generator if his XP is sufficient for that generator. The challenge is to find the maximum number of generators Bob can hack by alternating generator types.
### Overview of the Code
1. **Data Structures**:
- **`Generator` Struct**: Represents each generator with its type, XP required, and XP generated.
- **`MaxHeap`**: A custom max-heap structure is used to always choose the generator that yields the maximum XP from the set of generators that Bob can currently hack.
2. **Algorithm Outline**:
- Separate the generators into two lists: one for AC generators and one for DC generators.
- Sort these lists based on the XP needed in ascending order.
- Use two max-heaps (one for AC and one for DC) to keep track of which generators can be hacked based on Bobs current XP.
- Simulate Bob hacking generators, alternating between AC and DC types, and try both possible starting types to find the maximum number of generators Bob can hack.
### Detailed Explanation of the Code
#### 1. Generator Struct and Sorting Function
- The `Generator` struct stores the generator type, XP required (`xpNeeded`), and XP generated (`xpGenerated`).
- The `compareByXpNeeded` function is used to sort generators based on the XP needed in ascending order. This helps Bob efficiently find which generators are available based on his current XP.
#### 2. Heap Implementation
- **Heap Initialization**: The `initHeap` function initializes a max-heap for storing pointers to generators.
- **Heapify Up and Down**: These functions (`heapifyUp`, `heapifyDown`) maintain the max-heap property:
- `heapifyUp`: Ensures that after inserting a new element, the heap remains valid by moving the element up as needed.
- `heapifyDown`: Adjusts the heap after removing the top element, ensuring the next maximum element is at the top.
- **Push and Pop**: `pushHeap` adds a generator to the heap, and `popHeap` removes and returns the generator with the highest XP generated value. This allows Bob to always select the generator that maximizes his XP gain at each step.
#### 3. Hacking Strategy (`hackGenerators` Function)
The `hackGenerators` function implements the core logic:
1. **Separating Generators by Type**:
- It creates two arrays (`ac` for AC generators and `dc` for DC generators) and populates them based on the type of each generator.
- Both arrays are sorted by `xpNeeded` using `qsort`.
2. **Simulating the Hacking Process**:
- The function tests two scenarios: starting with an AC generator (`startingType = 0`) and starting with a DC generator (`startingType = 1`).
- For each starting type:
- Initialize indices (`acIdx` and `dcIdx`) to iterate through the sorted lists.
- Maintain two max-heaps (`acHeap` and `dcHeap`) to track available generators that Bob can hack.
- While there are generators that Bob can hack:
- Add all AC generators Bob can currently hack (where `xpNeeded <= xp`) to `acHeap` if the current type is AC.
- If a generator is available in the heap, hack it (pop from the heap), increase XP, and increment the hack count.
- Switch to the other type (AC to DC or DC to AC) for the next iteration.
- The maximum number of generators hacked in each scenario is tracked to determine the best strategy.
3. **Return the Maximum Number of Hacks**:
- The function returns the maximum value between the two scenarios (starting with AC or starting with DC).
### 4. Main Function
- The `main` function reads the input, initializes the array of generators, and calls `hackGenerators` with Bob's initial XP and the list of generators.
- It then prints the result (maximum number of generators Bob can hack) and frees the allocated memory.
### Example Walkthrough
Let's walk through an example to see how the algorithm works:
#### Input Example
```
5 4
1 3 2
0 4 1
0 10 5
1 7 3
0 22 9
```
- **Initial XP**: 4
- **Generators**:
- (Type: DC, XP Needed: 3, XP Generated: 2)
- (Type: AC, XP Needed: 4, XP Generated: 1)
- (Type: AC, XP Needed: 10, XP Generated: 5)
- (Type: DC, XP Needed: 7, XP Generated: 3)
- (Type: AC, XP Needed: 22, XP Generated: 9)
#### Simulation Details
1. **Separating and Sorting Generators**:
- AC generators: [(4, 1), (10, 5), (22, 9)]
- DC generators: [(3, 2), (7, 3)]
2. **Starting with DC**:
- Bob hacks DC (3, 2), gaining 2 XP (now XP = 6).
- Next, Bob hacks AC (4, 1), gaining 1 XP (now XP = 7).
- Bob hacks DC (7, 3), gaining 3 XP (now XP = 10).
- Finally, Bob hacks AC (10, 5), gaining 5 XP (now XP = 15).
- Total hacks: 4.
3. **Starting with AC**:
- Bob hacks AC (4, 1), gaining 1 XP (now XP = 5).
- Next, Bob hacks DC (3, 2), gaining 2 XP (now XP = 7).
- Bob hacks AC (10, 5), gaining 5 XP (now XP = 12).
- Finally, Bob hacks DC (7, 3), gaining 3 XP (now XP = 15).
- Total hacks: 4.
The maximum number of hacks is 4.
### Complexity Analysis
- **Time Complexity**:
- Sorting the generators takes \( O(n \log n) \).
- Heap operations (push and pop) each take \( O(\log n) \). Since each generator is pushed and popped at most once, the overall time complexity remains \( O(n \log n) \).
- **Space Complexity**:
- The space used for the heaps is \( O(n) \), and the arrays (`ac` and `dc`) also take \( O(n) \). Thus, the space complexity is \( O(n) \).
### Summary
The code efficiently determines the maximum number of generators Bob can hack using a combination of sorting and max-heap operations to select the optimal generators at each step. By testing both starting scenarios (AC first and DC first), the code guarantees the optimal solution.
# Code Block 3
### Heaps Overview
Heaps are tree-based structures used for efficient priority queues. They are complete binary trees with two types:
- **Min-Heap**: Root is the smallest element.
- **Max-Heap**: Root is the largest element.
### Max-Heap Properties
- Each nodes value is greater than or equal to its childrens.
- The largest value is always at the root.
- Its a **complete** binary tree: fully filled except possibly the last level, filled from left to right.
### Max-Heap Operations
1. **Insertion**:
- Add the new element at the next available spot.
- **Heapify Up**: Swap with the parent until the heap property is restored.
2. **Deletion (Remove Max)**:
- Remove the root.
- Move the last element to the root.
- **Heapify Down**: Swap with the largest child until the heap property is restored.
3. **Peek/Top**: Access the maximum element (root) in \(O(1)\).
### Heapify Process
- **Heapify Up**: Used during insertion to move the element up until its in the right spot.
- **Heapify Down**: Used during deletion to move the new root down to maintain the max-heap property.
### Array Representation
Heaps are often stored in arrays:
- **Left Child**: \(2i + 1\)
- **Right Child**: \(2i + 2\)
- **Parent**: \((i - 1) / 2\)
### Applications
- **Priority Queues**: Efficient access to max/min elements.
- **Heap Sort**: Sorts in \(O(n \log n)\).
- **Graph Algorithms**: E.g., Dijkstras shortest path.
### Advantages and Disadvantages
**Pros**:
- Fast insertion/deletion (\(O(\log n)\)).
- Efficient array representation.
**Cons**:
- No efficient ordered traversal (unlike BST).
- Limited to max/min element access unless augmented.
Heaps provide efficient operations for scenarios where fast access to max/min elements is needed.
# Excalidraw Data
## Text Elements
0:00 Intro
0:40 For the greater good - Max heap
12:59 Max heaps definition
15:44 Volcano research - Intervals + AVL Tree
30:10 Volcano Research - Overview of Code
33:48 IMPORTANT: Volcano Research - AVL Tree Code ^isYmpx3J
## Element Links
FKUJp7bM: [[Practical 5#Code Block]]
9gZqEpBZ: [[Practical 5#Code Block 1]]
zteJnsSi: [[Practical 5#Code Block 2]]
mivngCCL: [[Practical 5#Code Block 3]]
%%
## Drawing
```compressed-json
N4KAkARALgngDgUwgLgAQQQDwMYEMA2AlgCYBOuA7hADTgQBuCpAzoQPYB2KqATLZMzYBXUtiRoIACyhQ4zZAHoFAc0JRJQgEYA6bGwC2CgF7N6hbEcK4OCtptbErHALRY8RMpWdx8Q1TdIEfARcZgRmBShcZQUebQAWbQBGGjoghH0EDihmbgBtcDBQMBKIEm4IIQA2egBxABUAWQBlAAVG3CTsABEAJQAGXGcAKW7+gGFUkshYRAqAM0CETyp+
UsxuZyqAZkSeAFY1yBhNniqq7R4Adl3tq8PCyAoSdW59pKOpBEJlaW4k7bbT7WZTBbj9T7MKCkNgAawQ4zY+DYpAq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oYB0+GM6EAA
```
%%

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,39 @@
---
type: practical
---
## Lombok
### `@AllArgsConstructor`(onConstructor_=@Annotation)
- Creates a public constructor which takes in all args
- `onConstructor_`: Places an annotation on the constructor
### `@Data`
A shortcut for `@ToString`, `@EqualsAndHashCode`, `@Getter` on all fields, and `@Setter` on all non-final fields
## Spring
### `RestController`
Extends Controller. Used to declare a class as a REST controller
### `@Autowired`
- Annotates a constructor
- Basically, it figures out dependency injection on its own
### `@[Get/Post/Put/Delete]Mapping("/path/")`
Makes an endpoint at path.
### `@RequestParam`
Describe the param and type
```java
@GetMapping("/api/foos")
@ResponseBody
public String getFoos(@RequestParam String id) {
return "ID: " + id;
}
```
### Beans
![[Beans.canvas|Beans]]

View File

@ -0,0 +1,75 @@
---
type: practical
---
### Point: Trying to avoid technical debt
In software development and other information technology fields, technical debt (also known as design debt or code debt) is the implied cost of future reworking because a solution prioritizes expedience over long-term design.
## Assignment explanation
![[assignment_app.canvas|assignment_app]]
![[assignment_organization.canvas|assignment_organization]]
So essentially, each team specifies a module, then they exchange the specifications and start working. Then, each team PRs into each other's repo and we get a working thing.
## Diagramming
Diagramming *is very important* when it comes to communication. Doesn't seem like they ***need*** us to use UML, but I'm gonna learn it anyway.
### C4 model
C4 stands for Context, Containers, Components, and Code.
1. **Context Diagram:**
- Shows the system being modeled and its interactions with external entities such as users, systems, or services.
- Provides a high-level overview of the system's purpose and relationships with the outside world.
2. **Container Diagram**:
- Breaks down the system into high-level containers (e.g., web applications, databases, microservices).
- Shows how these containers interact with each other and with external systems.
- Defines technologies used within each container.
3. **Component Diagram**:
- Focuses on the components within a container and their relationships.
- Components represent significant building blocks like classes, libraries, or microservices.
4. **Code** (***UML***):
- Provides a detailed view at the code level, such as classes, methods, and relationships.
### Key UML Diagram Types
1. **Structural Diagrams**: Describe the static structure of a system.
- **Class Diagram**: Shows classes, their attributes, methods, and relationships among objects. Fundamental to object-oriented design.
- **Object Diagram**: Represents instances of classes (objects) at a particular moment.
- **Component Diagram**: Illustrates the organization and dependencies among software components (e.g., libraries).
- **Deployment Diagram**: Depicts the physical deployment of artifacts on nodes like servers or devices.
2. **Behavioral Diagrams**: Capture the dynamic behavior of a system.
- **Use Case Diagram**: Visualizes functional requirements and interactions between users (actors) and the system.
- **Sequence Diagram**: Shows object interactions arranged in a time sequence.
- **Activity Diagram**: Represents workflows of stepwise activities and actions.
- **State Machine Diagram**: Depicts states and transitions of an object throughout its lifecycle.
3. **Interaction Diagrams**: Focus on object interactions.
- **Communication Diagram**: Focuses on the communication between objects and the associations between them.
- **Timing Diagram**: Represents timing constraints on object interactions.
#### Relationships
- **Association**: Related but **independent**.
- **Aggregation**: One contains the other, but the **parts can exist independently**.
- **Composition**: Parts **cannot exist** without the whole.
- **Dependency**: Self-explanatory
- **Realization**: `implements`
- **Generalization**: `extends`
#### Key Components of a Sequence Diagram
1. **Objects/Participants**: These are the entities involved in the interaction, such as classes, components, or subsystems.
2. **Lifelines**: A lifeline is a dashed vertical line that represents the passage of time.
3. **Activation Bars**: Represent duration an object is active while processing messages
4. **Messages**: Arrows between lifelines that show communication between objects. Messages can be of different types:
- **Synchronous Messages**: Represented by a solid line with a filled arrowhead, indicating a call that waits for a return.
- **Asynchronous Messages**: Represented by a solid line with an open arrowhead, indicating a call that doesn't wait for a response.
- **Return Messages**: Dashed arrows that show the return of control or data after a message is processed.
5. **Loops and conditions**: Control flow
![[sequence_diagram.png]]

View File

@ -0,0 +1,189 @@
---
type: practical
---
## IoC Definition
Inversion of Control is a design principle in which custom code is executed by an external code. The control of parts of your code is delegated to another logical unit.
>Think of when you submit assignment to Themis.
You did not write the tests in the program, but they still get executed against your program, as long as the input and output processing is correct.
## Dependency Injection
It is a technique where an object receives (or is "injected" with) other objects that it depends on, rather than creating those objects itself.
### Example
<u>CoffeeBean.java</u>
```java
public class CoffeeBean {
private String type;
public CoffeeBean(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
```
<u>Water.java</u>
```java
public class Water {
private int amount;
public Water(int amount) {
this.amount = amount;
}
public int getAmount() {
return amount;
}
}
```
<u>CoffeeMachine.java</u>
```java
public class CoffeeMachine {
private CoffeeBean coffeeBean; // <--------
private Water water; // Dependencies
public CoffeeMachine(CoffeeBean coffeeBean, Water water) {
this.coffeeBean = coffeeBean;
this.water = water;
}
public void makeCoffee() {
if (coffeeBean == null || water == null) {
System.out.println("He-Hell nah.");
return;
}
System.out.println("Making coffee with " + coffeeBean.getType() + " beans and " + water.getAmount() + "ml of water.");
}
}
```
And then when we instantiate `CoffeeMachine`, we **pass instances** of `Water` and `coffeeBean`.
### How Does Spring Use DI?
Spring manages the **creation** and **wiring** of objects for you. Heres how it works:
1. **Beans**: Objects managed by Spring.
2. **Spring Container**: Factory which creates beans. You always need the container.
### `@Container` vs `@Bean` vs `@Component`
- A `Component` is a `Container` all of which's methods are `Beans`
- `Bean` is a Method managed by Spring
- `Container` is the class decorator which tells spring that we have beans inside
## Spring Basics
![Video](https://www.youtube.com/watch?v=LSEYdU8Dp9Y)
Spring is a **framework**, hence *its* design has to be followed.
### Quickstart
1. Import (mvn)
2. Add `@SpringBootApplication`, import and `SpringApplication.run(Main.class)`
#### Handling a REST client
Example:
```java
// Blah blah imports blah
@Controller
public class Control {
@GetMapping("/api/path_to_resource/{dynamicValue}") // <- GET
public String lmao(@PathVariable String value) {
return "You gave me " + value;
}
@PostMapping("/api/setLol") // <- POST
public String lmao(@RequestBody String value) {
System.out.println("Received: " + value);
}
// We can also parse json n stuff
@PostMapping("/api/yoMama")
public ResponseEntity<String> parseJson(@RequestBody yoMama obj) {
String response = "Received object: name = " + obj.getName() +
", number = " + obj.getNumber() +
", hot = " + obj.isHot();
System.out.println(response);
return ResponseEntity.ok(response);
}
}
}
class yoMama {
@Getter @Setter
private String name;
@Getter @Setter
private int number;
@Getter @Setter
private boolean hot;
public yoMama() {
}
}
```
## Beans
> beans can only be uses by beans
![[Beans.canvas|Beans]]
### Definition
- Any class that is a dependency and/or is dependent
### Purpose
- Solve the problem of dependencies by traversing the project's classes and instantiating them topologically in a procedural manner
### Annotations
Check out the [[Annotation Repository]].
## Components
### Entity
- Table in a DB
- Annotated with `@Entity`
- Instance corresponds to a row in the DB table
### DTO (Data Transfer Object)
- Java object used to transfer data b/n layers
- Decouple internal data from data exposed to client
- Contain only the necessary fields
### Repository
- Encapsulates storage, retrieval and search from a DB
- Usually extended from `CrudRepository` or `JpaRepository`
- Provides CRUD (Create, Read, Update and Delete) operations and query methods for an entity
### Controller
- Handles HTTP requests and returns responses
- Maps HTTP requests to specific methods
- Usually annotated with `@RestController` and `@RequestMapping`
### Service
- Class that contains logic and operations
- Intermediary between [Controller](IoC%20and%20Spring.md#Controller) and [Repository](IoC%20and%20Spring.md#Repository)
- Annotated with `@Service`

View File

@ -0,0 +1,53 @@
---
type: practical
---
## Pyramid
![[Testing Pyramid.png]]
## Negative results
- **Error**: Mistake made by a human
- **Fault**: A manifestation of an error in software
- **Bug and Defect** are basically the same as Fault
- **Failure**: Inability of a system or component to perform its required function
## Types of tests
### Functional testing
| Fancy Words | Simpler Explanation | Stupid Dumb Word |
| ------------------- | -------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| Unit Testing | Testing individual components or pieces of code in isolation. | Piece by piece testing |
| Integration Testing | Testing the interaction between integrated modules or components to ensure they work together as expected. | Mix and match testing |
| System Testing | Testing the entire system as a whole to verify it meets specified requirements. | Whole thing testing |
| Acceptance Testing | Testing to determine whether the system meets the business needs and requirements, often performed by the end-users. | Ready or not |
| Regression Testing | Re-running tests to ensure that new code changes havent broken existing functionality. | Did we break it again? |
| Sanity Testing | A quick round of testing to check if a specific function or bug fix works as intended. | Quick check testing |
| Smoke Testing | A basic check to ensure the softwares core functionality works and it's stable enough for more in-depth testing. | Is it on fire? |
| Usability Testing | Testing how user-friendly and intuitive the software is for the end-user. | Easy of use testing |
### Non-functional testing
| Fancy Words | Simpler Explanation | Stupid Dumb Word |
| --------------------- | ----------------------------------------------------------------------------------------- | -------------------------- |
| Performance Testing | Testing how well the software performs under different conditions. | How fast does it run? |
| Load Testing | Testing how the software behaves under expected user load. | How much can it carry? |
| Stress Testing | Testing the limits of the software by pushing it beyond normal operational capacity. | When will it break? |
| Volume Testing | Testing the software with a large amount of data to see if it handles it well. | How much data can it take? |
| Scalability Testing | Testing how well the software scales when the user load or data volume increases. | Can it grow? |
| Recovery Testing | Testing the software's ability to recover after a failure or crash. | Can it unfuck itself? |
| Compatibility Testing | Testing how well the software works across different environments, platforms, or devices. | Does it work with others? |
| Security Testing | Testing how well the software protects against unauthorized access and vulnerabilities. | Can it be broken into? |
## Black box vs White box
| Black box | White box |
| --------------------------------- | ---------------------- |
| Done by tester | Done by devs |
| Internal code unknown | Knowledge is required |
| Functional testing | Structure testing |
| No programming skills necessary | bruh |
| Do it break, do it work, is nice? | Do it cover all cases? |

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -0,0 +1,18 @@
{
"nodes":[
{"id":"3fc2b54b9eadc6ba","x":239,"y":-360,"width":501,"height":357,"color":"6","type":"group","label":"Server"},
{"id":"bafe15ec55f029a6","x":-180,"y":-360,"width":602,"height":140,"color":"5","type":"group","label":"Client-side"},
{"id":"8f80fb123ea6ce09","type":"text","text":"REST Client\n(e.g. `requests` )","x":47,"y":-320,"width":192,"height":60},
{"id":"3cfeacd18cd26023","type":"text","text":"User","x":-140,"y":-304,"width":100,"height":29},
{"id":"aa15bb82396562f8","type":"text","text":"Book Review API","x":414,"y":-320,"width":191,"height":60},
{"id":"e14bb42f26a15f31","x":260,"y":-140,"width":214,"height":117,"type":"text","text":"API Service (spring)\nExpose endpoints to manage books and reviews."},
{"id":"ac364961ecf80527","type":"text","text":"Database (MySQL)\n\nStore resources","x":509,"y":-140,"width":214,"height":117}
],
"edges":[
{"id":"902c39262a6ace6a","fromNode":"3cfeacd18cd26023","fromSide":"right","toNode":"8f80fb123ea6ce09","toSide":"left"},
{"id":"6ac86a9e5be59149","fromNode":"8f80fb123ea6ce09","fromSide":"right","toNode":"aa15bb82396562f8","toSide":"left"},
{"id":"7913e3356f9e0f7d","fromNode":"e14bb42f26a15f31","fromSide":"top","toNode":"aa15bb82396562f8","toSide":"bottom"},
{"id":"215231208aa4fd5a","fromNode":"ac364961ecf80527","fromSide":"top","toNode":"aa15bb82396562f8","toSide":"bottom"},
{"id":"f2b912e7b34b6df2","fromNode":"e14bb42f26a15f31","fromSide":"right","toNode":"ac364961ecf80527","toSide":"left"}
]
}

View File

@ -0,0 +1,19 @@
{
"nodes":[
{"id":"96f9d1aa2dfe6e72","type":"file","file":"Advanced Programming/assets/assignment/assignment_app.canvas","x":-120,"y":-340,"width":400,"height":400},
{"id":"aaa14d4a63d50f5b","type":"text","text":"Book Management Module","x":-144,"y":222,"width":206,"height":87},
{"id":"e8482c8d0391157a","type":"text","text":"Group 1","x":-205,"y":406,"width":123,"height":60,"color":"4"},
{"id":"8ae0f3cd568d7382","type":"text","text":"Review Management Mode","x":200,"y":222,"width":211,"height":87},
{"id":"43a3e65e358e014b","type":"text","text":"Group 1","x":139,"y":406,"width":123,"height":60,"color":"4"},
{"id":"7eec19f08b2193b6","type":"text","text":"Group 2","x":349,"y":406,"width":125,"height":60,"color":"1"},
{"id":"beea6cec3cb68314","type":"text","text":"Group 2","x":0,"y":406,"width":125,"height":60,"color":"1"}
],
"edges":[
{"id":"71a504bf559dfe18","fromNode":"96f9d1aa2dfe6e72","fromSide":"bottom","toNode":"aaa14d4a63d50f5b","toSide":"top"},
{"id":"d39fe30e3ea5696a","fromNode":"96f9d1aa2dfe6e72","fromSide":"bottom","toNode":"8ae0f3cd568d7382","toSide":"top"},
{"id":"8edc4e274f6adbb7","fromNode":"aaa14d4a63d50f5b","fromSide":"bottom","toNode":"e8482c8d0391157a","toSide":"top","label":"Specify"},
{"id":"c93e390557a144b8","fromNode":"aaa14d4a63d50f5b","fromSide":"bottom","toNode":"beea6cec3cb68314","toSide":"top","label":"Develop"},
{"id":"a4dc36f27812fb63","fromNode":"8ae0f3cd568d7382","fromSide":"bottom","toNode":"43a3e65e358e014b","toSide":"top","label":"Develop"},
{"id":"32534b3546e962c4","fromNode":"8ae0f3cd568d7382","fromSide":"bottom","toNode":"7eec19f08b2193b6","toSide":"top","label":"Specify"}
]
}

View File

@ -0,0 +1,15 @@
{
"nodes":[
{"id":"e19bd648197c7e91","type":"text","text":"@Component","x":-40,"y":-200,"width":163,"height":60,"color":"1"},
{"id":"c629af864eb7638e","type":"text","text":"@Service","x":-341,"y":-20,"width":250,"height":60,"color":"3"},
{"id":"04cbffca8594824f","type":"text","text":"@Controller","x":-45,"y":-20,"width":173,"height":60,"color":"5"},
{"id":"2b772d03013468ca","type":"text","text":"@Repository","x":195,"y":-20,"width":250,"height":60,"color":"6"},
{"id":"d611968995b82f13","type":"text","text":"@RestController","x":-83,"y":140,"width":250,"height":60,"color":"5"}
],
"edges":[
{"id":"dff0e847a79aaed0","fromNode":"e19bd648197c7e91","fromSide":"bottom","toNode":"c629af864eb7638e","toSide":"top"},
{"id":"d79330e26a43a6ec","fromNode":"e19bd648197c7e91","fromSide":"bottom","toNode":"04cbffca8594824f","toSide":"top"},
{"id":"c9e60f81cb276612","fromNode":"04cbffca8594824f","fromSide":"bottom","toNode":"d611968995b82f13","toSide":"top"},
{"id":"435c4bfbc0474449","fromNode":"e19bd648197c7e91","fromSide":"bottom","toNode":"2b772d03013468ca","toSide":"top"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@ -0,0 +1,162 @@
---
type: practical
---
- [Updating information](#Updating%20information)
- [The existence of the `PATCH` request](#The%20existence%20of%20the%20%60PATCH%60%20request)
- [Usage of `PUT`](#Usage%20of%20%60PUT%60)
- [Complete request example](#Complete%20request%20example)
- [Incomplete request example](#Incomplete%20request%20example)
- [Usage of `POST`](#Usage%20of%20%60POST%60)
- [General "style" remarks](#General%20%22style%22%20remarks)
- [Conclusion / TL;DR](#Conclusion%20/%20TL;DR)
## Updating information
Can we have optional fields in the update `PUT` and `POST` request?
### The existence of the `PATCH` request
>The **`PATCH`** HTTP method applies partial modifications to a resource.
>`PATCH` is somewhat analogous to the "update" concept found in [CRUD](https://developer.mozilla.org/en-US/docs/Glossary/CRUD) (in general, HTTP is different than [CRUD](https://developer.mozilla.org/en-US/docs/Glossary/CRUD), and the two should not be confused).[^1]
Hence, this definition also answers the question as to why we **should be careful with the usage of `PATCH`** if we consider it.
### Usage of `PUT`
>The PUT method requests that the state of the target resource be
created or replaced with the state **defined by the representation**
**enclosed in the request message payload**. [^3]
This implies that complete resource representation **is required** (all the fields), as Jackson(Spring) will reset the missing ones to their default values (e.g. int = 0, boolean = false, String = null, etc.)
#### Complete request example
*Request:*
```json
{
"isbn": "978-3-16-148410-0",
"name": "Among us story",
"author": "Yo mama",
"genre": "Horror",
"publisher": "Team 22",
"publishDate": "2023-09-01",
"pages": 320
}
```
*Response:*
```json
<<< 200 OK
{
"isbn": "978-3-16-148410-0",
"name": "Among us story",
"author": "Yo mama",
"genre": "Horror",
"publisher": "Team 22",
"publishDate": "2023-09-01",
"pages": 320
}
```
#### Incomplete request example
(this is assuming the above request happened already)
*Request:*
```json
{
"isbn": "978-3-16-148410-0",
"name": "Among us story",
"publisher": "Team 22",
"pages": 320
}
```
*Response*:
```json
<<< 200 OK
{
"isbn": "978-3-16-148410-0",
"name": "Among us story",
"author": null,
"genre": null,
"publisher": "Team 22",
"publishDate": null,
"pages": 320
}
```
### Usage of `POST`
Contrary to `PUT`:
>The `POST` method is **used to request that the target resource process the enclosed representation according to the resource's own specific semantics**. The meaning of a `POST` request is determined by the server and is usually dependent on the resource identified by the Request-URI.[^4]
Therefore we *can* send requests which contain data that are non-complete resource representations. We do have to explain this to the other team tho...
i.e.
*Request:*
```json
{
"isbn": "978-3-16-148410-0"
}
```
*Response:*
``` json
<<< 201 Created
{
"isbn": "978-3-16-148410-0",
"name": null,
"author": null,
"genre": null,
"publisher": null,
"publishDate": null,
"pages": 0
}
```
## General "style" remarks
(based on the API conventions + CRUD principle)
>The base URL should be neat, elegant, and simple so that developers using your product can easily use them in their web applications. A long and difficult-to-read base URL is not just bad to look at, but can also be prone to mistakes when trying to recode it. Nouns should always be trusted.[^2]
Hence, using a verb in `POST /api/v1/book/create` and `PUT /api/v1/book/update` is not ideal.
Table[^2] of common conventions for the usage of HTTP requests:
| **Resource** | `POST` | `GET` | `PUT` | `DELETE` |
| ------------------- | --------------------------------- | ----------------------------------- | --------------------------------------------- | -------------------------------- |
| /customers | Create a new customer | Retrieve all customers | Bulk update of customers | Remove all customers |
| /customers/1 | Error | Retrieve the details for customer 1 | Update the details of customer 1 if it exists | Remove customer 1 |
| /customers/1/orders | Create a new order for customer 1 | Retrieve all orders for customer 1 | Bulk update of orders for customer 1 | Remove all orders for customer 1 |
Hence, in our case:
| **Resource** | `POST` | `GET` | `PUT` | `DELETE` |
| ------------- | ----------------- | -------------------------------------------------------- | ------------------------------------------------ | ----------------------- |
| /books | Create a new book | Retrieve all books (+ optional parameters for filtering) | 405 | Remove all books |
| /books/{isbn} | 405 | Retrieve the details for book with `isbn` | Update the details of book with `isbn` if exists | Remove book with `isbn` |
## Conclusion / TL;DR
Given the information provided above, I propose we change the current specification as follows:
| Method | Old URL/Description | New URL/Description | Reasoning |
| -------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `POST` | `/api/v1/book/create` - Create book - pass JSON body (isbn is required) | `/api/v1/books` - Create a book - pass JSON body (isbn is required) | Use resource-based naming convention (`books` as a collection). HTTP POST implies creation; no need for `/create`. |
| `PUT` | `/api/v1/book/update` - Update book - pass JSON body (isbn is required) | `/api/v1/books/{isbn}` - Update a specific book - pass JSON body | Use path parameter (`{isbn}`) to specify which book to update. HTTP PUT implies updating a specific resource. |
| `GET` | `/api/v1/book?genre={genre}&author={author}&data="csv"` - Get book(s) by property in csv/json format | `/api/v1/books?genre={genre}&author={author}` - Get books by property. Use `Accept` header for csv/json format | Use plural `books` for collections. Use HTTP `Accept` header for content negotiation (CSV/JSON), keeping URLs clean. |
| `DELETE` | `/api/v1/book?genre={genre}&author={author}` - Delete book(s) by property | `/api/v1/books` - Delete books - pass filter criteria in body or delete one by `/api/v1/books/{isbn}` | `DELETE` requests with body for filtering criteria, or use path param for deleting a single resource for better clarity. |
| `POST` | `/api/v1/book/import?data="csv"` - Import books from csv/json file (isbn is required for each) | `/api/v1/books/import` - Import books from CSV/JSON file - pass file in body; use `Content-Type` header | Use resource-based naming (`books/import`). The `Content-Type` header indicates file type (CSV/JSON); keep query params clean. |
[^1]: [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH)
[^2]: [Swagger](https://swagger.io/resources/articles/best-practices-in-api-design/)
[^3]: [RFC 7231 - PUT](https://datatracker.ietf.org/doc/html/rfc7231#autoid-37)
[^4]: [RFC 7231 - POST](https://datatracker.ietf.org/doc/html/rfc7231#autoid-36)

View File

@ -0,0 +1,43 @@
---
type: practical
---
## Genre
- Cool, nice. We will extend.
## FileService
- `importBooks` doesn't actually save books
- CSV parsing might fail if there are commas in the data itself
- Hardcoded CSV column names (just an observation, not necessarily bad)
- File creation creates temp files without deleting them
## BookService
- `createBook` doesn't ensure isbn uniqueness
## BookRepository
- Our documentation is not updated. The class map cointains findByISBN.
- Only 'isbn' is supported. Implement:
- findByAttributes(BookAttributes attrs)
- findByID(long pk)
- deleteByAttributes
- deleteByID
## BookAttributes
- Every field should be private (@Data automatically adds gsetters)
- Perhaps add data validation? Not necessary.
## Book
- Attributes can be null. Add null checks in getters and setters to avoid. We don't want null ptr exceptions
## BookController
- Do not interact with repository directly. Go through service.
## BookService
- `createBook` returns true always, no matter what the status is
- matchingAny is OR, false positives might be returned. Perhaps use matchingAll? Not sure about this.
- `deleteBooksByAttribute` is missing

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
---
excalidraw-plugin: parsed
tags:
- excalidraw
type: practical
---
==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'
# Excalidraw Data
## Text Elements
%%
## Drawing
```compressed-json
N4KAkARALgngDgUwgLgAQQQDwMYEMA2AlgCYBOuA7hADTgQBuCpAzoQPYB2KqATLZMzYBXUtiRoIACyhQ4zZAHoFAc0JRJQgEYA6bGwC2CgF7N6hbEcK4OCtptbErHALRY8RMpWdx8Q1TdIEfARcZgRmBShcZQUebQAWbQBGGjoghH0EDihmbgBtcDBQMBKIEm4IAFFJYgAOeIB5ChyAZQpmOAB9AA0AaQBWAClh5VSSyFhECoAzQIRPKn5SzG5n
eKSABm0efqXIGFWAZiSANm0Adn7z2qSdvYgKEnVueNr7yQRCZWluJP6N+7WZTBbgAwoCKCkNgAawQAGE2Pg2KQKgBiJIIDEYsalTS4bDQ5RQoQcYgIpEoiSQ6wdXCBbI4yDTQj4fAtWAgiSCDyMiDMSEwhAAdSekm4fHBfIFsPZME56G55XuxO+HHCuTQSXubDg+LUB01GzB4wgROEcAAksQNag8gBde6zXCZK3cDhCVn3QikrAVXAbXnE0lq5g2
92eyVhebio0bQ79HhJc7ne6MFjsLhoeIATlTTFYnAAcpwxL9DonDvUNtndpLCMwACLpKDRtCQoQIe6aYSkyrBTLZMMe/D3IRwYi4FvEX7nQ4bV48bMnE79WopyVEDjQt3D+5Igmt1DTAhhe5wNjenL5cFgArjErG+8bG8Om93p97ErOJIvz/v8bfp+YDfr+b43sBWrgc+96vve/5fpB95gIcoFwVBQG1Kh4zwchQE8CcWElDhJxAZWhG3uBmxAf0
P4wX+lGHEBK7kThSZAdcLHgTwj7jNm0HjLB2FcRKSHZphdFgUhPDxEBmzxJxUkyZRGziQJ9GKbJGznAp97SZpKESWhUmMeBfE6eMPAifeNzmSUibsQZamSfebHgf0jklIJRGUbWSHrLZYC3HhqmeepulAc42YBTxCEhWAXkUUhgHgc4+EBclSWHB58VheMiH3s4ZGGUJSEmUl/nFd5SG+QV8Q8AF67lfVl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kBVV6q2taQHrUtg4AcHJtSQBmRsBlcHq3AJoGCDWcOmpoZtecUxSoBjquyREIdlRBwhsws62dbyCuwIBlABSMnKiEq
ANgN1G6iAGWotVQAqVsIIVVAAzAsymQ0JJdT6GbUo5C1JoLIH2oHVriGZOKogG2rdxPrIAHAQWo+olLCAoAm4Y5E6jLV2BmiCAbAK0E/VwAu1Paz9f2qymXiwUYGwgIwC2T5qDpaAY6l9i5DpBENnAXkGCv5AGBw1HEizplMHW7L+QEyRDchtQ0x4+k4AAiRABpw9zx1vSEAL0iAA===
```
%%

View File

@ -0,0 +1,16 @@
{
"nodes":[
{"id":"0b575c52e89e5e7f","x":-868,"y":-500,"width":1018,"height":660,"color":"1","type":"group","label":"Problem"},
{"id":"59984a2333620a30","type":"text","text":"Problem - Too much reused logic\n","x":-580,"y":-480,"width":320,"height":80},
{"id":"4a3daa677e26d98e","x":-763,"y":-235,"width":250,"height":155,"type":"text","text":"`@Entity`s (Book, Review, Album) all have an `id` and an `attributes` field."},
{"id":"189837e2bb3fcc18","x":-440,"y":-233,"width":250,"height":153,"type":"text","text":"Controllers and services for each entity perform almost identical operations."},
{"id":"1144a58bdce0327e","x":-848,"y":15,"width":308,"height":125,"type":"text","text":"The `@Embeddable` attributes are also functionally the same, although with different values"},
{"id":"5739ca50af3e054a","x":-120,"y":-235,"width":250,"height":117,"type":"text","text":"Updates to common functionality require changes in multiple places"}
],
"edges":[
{"id":"2b2b795da278ff01","fromNode":"59984a2333620a30","fromSide":"bottom","toNode":"4a3daa677e26d98e","toSide":"top"},
{"id":"2ea24f6cc0e66abd","fromNode":"59984a2333620a30","fromSide":"bottom","toNode":"189837e2bb3fcc18","toSide":"top"},
{"id":"6b94289b63a6655a","fromNode":"4a3daa677e26d98e","fromSide":"bottom","toNode":"1144a58bdce0327e","toSide":"top"},
{"id":"c4ea927674cd8e4d","fromNode":"59984a2333620a30","fromSide":"bottom","toNode":"5739ca50af3e054a","toSide":"top"}
]
}

View File

@ -0,0 +1,89 @@
---
date: 02.09.2024
type: math
---
![Lecture](https://www.youtube.com/watch?v=564pn3Caoy)
## Definitions and Basic Concepts
### What is a Differential Equation?
A **differential equation** is an equation that involves an unknown function and its derivatives. It describes how a quantity changes with respect to another (e.g., time, space). Differential equations are widely used in physics, engineering, economics, biology, and many other fields to model various phenomena.
In mathematical terms, a differential equation can be written in the form:
$$
F\left(x, y, \frac{dy}{dx}, \frac{d^2y}{dx^2}, \ldots\right) = 0,
$$
where $y = y(x)$ is the unknown function, and $\frac{dy}{dx}, \frac{d^2y}{dx^2}, \ldots$ are its derivatives.
### What is an ODE?
An **Ordinary Differential Equation (ODE)** is a type of differential equation that involves functions of only one independent variable and its derivatives. The general form of an ODE is:
$$
F\left(x, y, y', y'', \ldots, y^{(n)}\right) = 0,
$$
where $x$ is the independent variable, $y = y(x)$ is the dependent variable, and $y', y'', \ldots, y^{(n)}$ represent the first, second, and $n$-th derivatives of $y$ with respect to $x$.
**Example:**
A simple example of an ODE is the first-order linear ODE:
$$
\frac{dy}{dx} + p(x)y = q(x),
$$
where $p(x)$ and $q(x)$ are given functions.
### What is a Linear and Homogeneous ODE?
- A **linear ODE** is an ODE in which the dependent variable $y$ and its derivatives appear to the first power and are not multiplied together. A general $n$-th order linear ODE can be written as:
$$
a_n(x)y^{(n)} + a_{n-1}(x)y^{(n-1)} + \cdots + a_1(x)y' + a_0(x)y = g(x),
$$
where $a_i(x)$ are functions of $x$ and $g(x)$ is a given function.
- A **homogeneous ODE** is a special type of linear ODE where $g(x) = 0$. The general form is:
$$
a_n(x)y^{(n)} + a_{n-1}(x)y^{(n-1)} + \cdots + a_1(x)y' + a_0(x)y = 0.
$$
**Example:**
The second-order homogeneous linear ODE:
$$
y'' - 3y' + 2y = 0
$$
is homogeneous because the right-hand side is zero. It can be solved by finding the characteristic equation and determining the general solution.
### What is a Particular Solution of ODEs?
A **particular solution** of an ODE is a specific solution that satisfies both the differential equation and any given initial or boundary conditions. It is different from the **general solution**, which contains arbitrary constants that represent the family of all possible solutions to the differential equation.
To find a particular solution, you substitute the initial or boundary conditions into the general solution and solve for the arbitrary constants.
**Example:**
Consider the ODE:
$$
y'' - 3y' + 2y = 0.
$$
The general solution is:
$$
y(x) = C_1 e^{2x} + C_2 e^x,
$$
where $C_1$ and $C_2$ are arbitrary constants. If we are given initial conditions $y(0) = 1$ and $y'(0) = 0$, we can substitute these into the general solution to find the values of $C_1$ and $C_2$, giving us a **particular solution**.
**Steps to find a Particular Solution:**
1. Find the general solution of the ODE.
2. Use the given initial or boundary conditions to determine the values of the arbitrary constants in the general solution.
3. Substitute these values back into the general solution to get the particular solution.

View File

@ -0,0 +1,89 @@
---
date: 04.09.2024
type: math
---
![Geometric Meaning of differential equations](https://www.youtube.com/watch?v=ccDMpj2UK_M)
## Integral Curve
- **What is it?**
An **integral curve** of a vector field is a curve that is tangent to the vector field at every point. In simpler terms, given a vector field (which can be thought of as arrows pointing in various directions), an integral curve is a path that follows the directions of these arrows.
![Integral Curve in a Vector Field](Integral%20Curve%20in%20a%20Vector%20field.png)
For a vector field $\mathbf{F}(x, y) = (P(x, y), Q(x, y))$ in 2D, an integral curve $\mathbf{r}(t) = (x(t), y(t))$ is a solution to the system of ordinary differential equations:
$$
\frac{dx}{dt} = P(x(t), y(t)), \quad \frac{dy}{dt} = Q(x(t), y(t)).
$$
**Example:**
Consider a simple vector field defined by $\mathbf{F}(x, y) = (y, -x)$. The integral curves of this field are solutions to the differential equations:
$$
\frac{dx}{dt} = y, \quad \frac{dy}{dt} = -x.
$$
Solving this system, we get solutions of the form:
$$
x(t) = A \cos(t) + B \sin(t), \quad y(t) = -A \sin(t) + B \cos(t),
$$
which represent circles centered at the origin.
## Cauchy Problem
![Cauchy formula explanation](https://www.youtube.com/watch?v=phbO46YJ1UQ&t=36s)
The Cauchy problem is a fundamental concept in the study of partial differential equations (PDEs[^1]}). It refers to the problem of finding a solution to a PDE given initial conditions along a certain hypersurface[^2].
- **How do we solve it?**
To solve a Cauchy problem for a PDE, we generally follow these steps:
1. **Formulate the PDE and Initial Conditions:**
Define the PDE and the initial conditions. The initial conditions are given on a hypersurface, such as a line (in 2D) or a plane (in 3D). For example, consider the wave equation in one dimension:
$$
\frac{\partial^2 u}{\partial t^2} - c^2 \frac{\partial^2 u}{\partial x^2} = 0.
$$
The initial conditions could be:
$$
u(x, 0) = f(x), \quad \frac{\partial u}{\partial t}(x, 0) = g(x),
$$
where$f(x)$and$g(x)$are given functions.
2. **Find a General Solution:**
Solve the PDE using a method that applies to the type of PDE (e.g., separation of variables, Fourier transforms, or characteristic methods). For the wave equation, the general solution can be written using d'Alembert's formula:
$$
u(x, t) = \frac{1}{2} \left( f(x - ct) + f(x + ct) \right) + \frac{1}{2c} \int_{x - ct}^{x + ct} g(s) \, ds.
$$
3. **Apply the Initial Conditions:**
Substitute the initial conditions into the general solution to find specific forms of the arbitrary functions or constants.
4. **Verify the Solution:**
Check that the obtained solution satisfies both the PDE and the initial conditions.
**Example:**
For the heat equation in one dimension:
$$
\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2},
$$
with initial condition$u(x, 0) = f(x)$, the solution is:
$$
u(x, t) = \frac{1}{\sqrt{4 \pi \alpha t}} \int_{-\infty}^\infty e^{-\frac{(x - \xi)^2}{4 \alpha t}} f(\xi) \, d\xi,
$$
which uses a convolution of the initial condition$f(x)$with a Gaussian kernel.
[^1]: Partial differential equation
[^2]: A **hypersurface** is a generalization of the concept of a surface to higher dimensions. Similar to matrices in linear algebra. In 3D, it's a plane, in 2D it's a curve/line.

132
Calculus 2/Linear ODEs.md Normal file
View File

@ -0,0 +1,132 @@
---
date: 09.09.2024
type: math
---
## Method of Variation of Constants
![Variation of parameters](https://www.youtube.com/watch?v=Ik3YW1JGr_A&pp=ygUgTWV0aG9kIG9mIFZhcmlhdGlvbiBvZiBDb25zdGFudHM%3D)
The **method of variation of constants** is a technique used to find a particular solution to a non-homogeneous linear differential equation. This method generalizes the solution of homogeneous equations by allowing the constants in the general solution to vary as functions of the independent variable.
Notice how it's similar to [Recurrence relations](Discrete%20Structures/Recurrence%20relations.md)
1. **Solve the homogeneous equation:** Start by solving the associated homogeneous differential equation. For an ODE of the form:
$$
y'' + p(x)y' + q(x)y = g(x),
$$
solve the homogeneous part:
$$
y'' + p(x)y' + q(x)y = 0.
$$
The general solution to the homogeneous equation will be:
$$
y_h(x) = C_1 y_1(x) + C_2 y_2(x),
$$
where $y_1(x)$ and $y_2(x)$ are linearly independent solutions.
2. **Replace constants with functions:** Replace the constants $C_1$ and $C_2$ with functions $u_1(x)$ and $u_2(x)$:
$$
y_p(x) = u_1(x)y_1(x) + u_2(x)y_2(x).
$$
3. **Set up equations for $u_1(x)$ and $u_2(x)$:** Differentiate $y_p(x)$ and use the condition that $u_1'(x)y_1(x) + u_2'(x)y_2(x) = 0$ to avoid second derivatives of $u_1(x)$ and $u_2(x)$. This gives:
$$
u_1'(x)y_1(x) + u_2'(x)y_2(x) = 0,
$$
$$
u_1'(x)y_1'(x) + u_2'(x)y_2'(x) = g(x).
$$
4. **Solve for $u_1'(x)$ and $u_2'(x)$:** Solve this system of equations to find $u_1'(x)$ and $u_2'(x)$.
5. **Integrate to find $u_1(x)$ and $u_2(x)$:** Integrate to find $u_1(x)$ and $u_2(x)$.
6. **Form the particular solution:** The particular solution is:
$$
y_p(x) = u_1(x)y_1(x) + u_2(x)y_2(x).
$$
## Bernoulli Equation
![Understanding the bernoulli equation](https://www.youtube.com/watch?v=DW4rItB20h4)
![Using the bernoulli equation](https://www.youtube.com/watch?v=iCN8nGXE29o)
A **Bernoulli equation** is a type of first-order nonlinear differential equation of the form:
$$
\frac{dy}{dx} + P(x)y = Q(x)y^n,
$$
where $n \neq 0, 1$.
- **When and how do we apply it?**
To solve a Bernoulli equation:
1. **Divide through by $y^n$:**
$$
y^{-n} \frac{dy}{dx} + P(x)y^{1-n} = Q(x).
$$
2. **Make a substitution:** Let $v = y^{1-n}$. Then $\frac{dv}{dx} = (1-n)y^{-n} \frac{dy}{dx}$.
3. **Rewrite the equation in terms of $v$:**
$$
\frac{dv}{dx} + (1-n)P(x)v = (1-n)Q(x).
$$
This is now a linear differential equation in $v(x)$.
4. **Solve the linear ODE for $v$:**
Use an integrating factor to solve for $v(x)$.
5. **Substitute back to find $y(x)$:**
Since $v = y^{1-n}$, solve for $y(x)$.
## Riccati Equation
![Explanation](https://www.youtube.com/watch?v=MoO7Jw06_PM)
A **Riccati equation** is a first-order nonlinear differential equation of the form:
$$
\frac{dy}{dx} = a(x) + b(x)y + c(x)y^2.
$$
- **When do we use it?**
Riccati equations are used in various fields such as control theory and fluid dynamics. They can sometimes be solved by making an appropriate substitution if a particular solution is known. In general, Riccati equations do not have a straightforward general solution like linear ODEs.
## $n \geq 2$ Linear ODE
![Constant coeff DEs](https://www.youtube.com/watch?v=is0F0u62IbY)
- **What do we do with those?**
For linear ODEs of order $n \geq 2$, we typically look for a general solution that is a linear combination of $n$ linearly independent solutions.
### General Properties of Spaces of Solutions of such $\epsilon$
- **Linear dependence:** Solutions $y_1(x), y_2(x), \ldots, y_n(x)$ are linearly independent if no solution can be written as a linear combination of the others.
- **Dimension:** The solution space of a linear homogeneous ODE of order $n$ has dimension $n$.
- **Fundamental theorem:** If $y_1(x), y_2(x), \ldots, y_n(x)$ are $n$ linearly independent solutions to an $n$-th order linear homogeneous ODE, then any solution can be written as:
$$
y(x) = C_1 y_1(x) + C_2 y_2(x) + \cdots + C_n y_n(x),
$$
where $C_1, C_2, \ldots, C_n$ are constants.
- **Structure of the space:** The space of solutions is a vector space, where each solution can be represented as a linear combination of a set of basis solutions.

View File

@ -0,0 +1,29 @@
---
type: math
---
## Finding particular solutions
### Definitions
- RHS $f(x) = P_{deg}(x) \cdot e^{rx}, p\in \mathbb{R}[x]$
- P is a polynomial
- Of **first kind**
- i.e. $e^{-3x}$; $2x^2+x -3$; $xe^x$
- RHS $f(x) = e^{rx} \cdot [P_{deg}(x)\\cdot \cos qx + Q_{deg_{2}}(x)\cdot \sin qx]$
- P, Q are polynomials
- Of **second kind**
- i.e. $2\cos x-\sin x$;$x^2e^{-x}\cos 2x$
- A "constant" is a polynomial of degree 0
##### Hyperbolic sin ($\sinh$)
Just as a fun fact, it doesn't fit neither of the kinds.
$$
\sinh x = \frac{e^x - e^{-x}}{2}
$$
### Method of undetermined coeffs
- RHS of 1st kind
- There exists a particular solution of the form
$$
y_{*}(x) = x^s \cdot R_{m}(x)\cdot e^{rx}
$$
- Where $s \rightarrow^{\text{{def}}} \text{multiplicity } r\in \mathbb{R}$ among the roots of characteristic polynomials for the LHS of the equation

View File

@ -0,0 +1,181 @@
---
date: 11.09.2024
type: math
---
## Separable ODE
- **What is it?**
A **separable ODE** is a type of first-order differential equation where the variables can be separated on opposite sides of the equation. In other words, it can be written in the form:
$$
\frac{dy}{dx} = g(x)h(y),
$$
where the right-hand side is a product of a function of $x$ and a function of $y$. This allows the equation to be rewritten so that all $y$-terms are on one side and all $x$-terms are on the other.
- **What are the solution steps?**
To solve a separable ODE, follow these steps:
1. **Rewrite the equation:** Separate the variables by moving all terms involving $y$ to one side and all terms involving $x$ to the other:
$$
\frac{1}{h(y)} \, dy = g(x) \, dx.
$$
2. **Integrate both sides:** Integrate both sides with respect to their respective variables:
$$
\int \frac{1}{h(y)} \, dy = \int g(x) \, dx.
$$
3. **Solve for $y(x)$:** Find the general solution by solving for $y$ in terms of $x$. This may involve finding an explicit or implicit form.
4. **Apply initial conditions (if any):** If an initial condition is provided (e.g., $y(x_0) = y_0$), substitute it into the general solution to find the particular solution.
**Example:**
Consider the separable ODE:
$$
\frac{dy}{dx} = xy.
$$
Separating variables:
$$
\frac{1}{y} \, dy = x \, dx.
$$
Integrating both sides:
$$
\ln |y| = \frac{x^2}{2} + C.
$$
Solving for $y$, we get:
$$
y(x) = Ce^{x^2/2}.
$$
## Equidimensional (EulerCauchy) Equation
![Solving](https://www.youtube.com/watch?v=zXZ4qmDpblE)
An **Equidimensional (EulerCauchy) equation** is a type of second-order linear differential equation with variable coefficients that are powers of the independent variable $x$. It has the form:
$$
x^2 y'' + ax y' + b y = 0,
$$
where $a$ and $b$ are constants.
- **How do we solve it?**
To solve the EulerCauchy equation:
1. **Use the substitution:** $y = x^m$, where $m$ is a constant to be determined.
2. **Find derivatives:** Compute $y'$ and $y''$ in terms of $m$:
$$
y' = mx^{m-1}, \quad y'' = m(m-1)x^{m-2}.
$$
3. **Substitute into the original equation:** Substitute $y$, $y'$, and $y''$ into the differential equation and simplify.
4. **Solve the characteristic equation:** The resulting equation will be a quadratic in terms of $m$:
$$
m(m-1) + am + b = 0.
$$
Solve this quadratic equation for $m$.
5. **Form the general solution:** Depending on the roots $m_1$ and $m_2$, the general solution will be:
- If $m_1 \neq m_2$: $y(x) = C_1 x^{m_1} + C_2 x^{m_2}$.
- If $m_1 = m_2$: $y(x) = (C_1 + C_2 \ln x) x^{m_1}$.
**Example:**
Solve $x^2 y'' - 4xy' + 6y = 0$.
1. Substitute $y = x^m$, $y' = mx^{m-1}$, and $y'' = m(m-1)x^{m-2}$.
2. The characteristic equation becomes:
$$
m(m-1) - 4m + 6 = 0 \implies m^2 - 5m + 6 = 0.
$$
3. Solving, we find $m_1 = 2$, $m_2 = 3$.
4. The general solution is:
$$
y(x) = C_1 x^2 + C_2 x^3.
$$
## Linear ODEs of Order 1
A **linear ODE of order 1** is a first-order differential equation that can be written in the form:
$$
\frac{dy}{dx} + P(x)y = Q(x),
$$
where $P(x)$ and $Q(x)$ are functions of $x$.
- **What are the rules for finding out if $\epsilon$ is homogeneous?**
An ODE is **homogeneous** if $Q(x) = 0$. Thus, the equation becomes:
$$
\frac{dy}{dx} + P(x)y = 0.
$$
In this case, the solution involves finding an integrating factor:
$$
\mu(x) = e^{\int P(x) \, dx}.
$$
Multiplying through by $\mu(x)$ makes the left side an exact derivative:
$$
\frac{d}{dx} \left( \mu(x) y \right) = 0,
$$
which can then be integrated to solve for $y(x)$.
## Examples of Different Types of Differential Equations
![Types of ODEs and their solutions](https://www.youtube.com/watch?v=ccRJtV6XWQE)
- **Non-linear:**
- An ODE that cannot be written in a linear form, for example:
$$
\frac{dy}{dx} = y^2 + x.
$$
The function $y^2$ makes it nonlinear.
- **Linear, Homogeneous:**
- An ODE where the function and its derivatives appear linearly and the right-hand side is zero:
$$
\frac{d^2y}{dx^2} - 3\frac{dy}{dx} + 2y = 0.
$$
Here, all terms involve $y$ or its derivatives to the first power, and the equation is set to 0.
- **Linear, Non-homogeneous:**
- A linear ODE with a non-zero right-hand side:
$$
\frac{d^2y}{dx^2} - 3\frac{dy}{dx} + 2y = e^x.
$$
The term $e^x$ makes it non-homogeneous.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,120 @@
---
type: theoretical
---
# Key Concepts
## Permutations
A permutation is an arrangement of objects in a specific order.
- Without Repetition[^1]: The number of permutations of $n$ distinct objects taken $r$ at a time is denoted by $nP_r$ and calculated as:
$$
nP_r = \frac{n!}{(n - r)!}
$$
- With Repetition (Unlimited Repeats)[^2]: If objects can repeat, the number of permutations of $n$ objects taken $r$ at a time is:
$$
n^r
$$
- With Repetition (Limited Repeats) [^3]: If there are $k_1$ objects of one type, $k_2$ of another, ..., and $k_t$ of type $t$, the number of permutations is:
$$
\frac{n!}{k_1! \cdot k_2! \cdot \ldots \cdot k_t!}
$$
---
## Combinations
A combination is a selection of objects where the order does not matter.
- Without Repetition: The number of combinations of $n$ distinct objects taken $r$ at a time is denoted by $nC_r$ or $\binom{n}{r}$, and is calculated as:
$$
nC_r = \binom{n}{r} = \frac{n!}{r!(n - r)!}
$$
- With Repetition: If repetition is allowed, the number of combinations of $n$ objects taken $r$ at a time is:
$$
\binom{n + r - 1}{r}
$$
---
## Examples
### Counting Strings Over an Alphabet
How many strings of length 3 can we form with the alphabet $\Sigma = \{a, b, c, d, e\}$?
- Since there are 5 choices for each position, the total number of strings is:
$$
5 \cdot 5 \cdot 5 = 5^3 = 125
$$
### Combinations Without Repetition
How many subsets of size 3 can we form from $A = \{a, b, c, d, e\}$?
- First, calculate the number of permutations:
$$
\frac{5!}{(5-3)!} = 5 \cdot 4 \cdot 3
$$
Divide by $3!$ to account for order:
$$
\frac{5 \cdot 4 \cdot 3}{3!} = 10
$$
### Combinations With Repetition
In a restaurant offering 12 desserts, how many ways can you choose 4 desserts (allowing repeats)?
- Using the formula for combinations with repetition:
$$
\binom{12 + 4 - 1}{4} = \binom{15}{4} = 1365
$$
---
## The Pigeonhole Principle
If $n$ items are placed into $m$ containers and $n > m$, at least one container must hold more than one item.
- If there are 13 pigeons and 12 pigeonholes[^6], at least one hole must contain more than one pigeon.
---
## Recurrence Relations
A recurrence relation defines a sequence by relating each term to previous terms.
- The Fibonacci sequence is defined by:
$$
F(n) = F(n - 1) + F(n - 2)
$$
with initial conditions $F(0) = 0$ and $F(1) = 1$.
### Solving Recurrence Relations
1. Backtracking[^7]: Repeatedly substitute the recurrence relation to find a pattern.
2. Linear Homogeneous[^8] Recurrence Relations:
These have the form:
$$
a_n = c_1 a_{n-1} + c_2 a_{n-2} + \ldots + c_k a_{n-k}
$$
"Homogeneous" means there is no constant term (e.g., no $+ b$ at the end).
- Solution: Solve the characteristic equation:
$$
r^k - c_1 r^{k-1} - c_2 r^{k-2} - \ldots - c_k = 0
$$
The roots $r$ determine the general form of the sequence.
[^1]: Permutations without repetition mean that each object can be used only once in the arrangement.
[^2]: Permutations with unlimited repetition mean objects can repeat any number of times.
[^3]: Limited repetition adjusts for identical items that are indistinguishable.
[^6]: The pigeonhole principle is a basic observation about "fitting" items into containers.
[^7]: Backtracking solves recurrences by substituting values until a pattern emerges.
[^8]: Linear homogeneous recurrence relations depend only on earlier terms, without constants.

View File

@ -0,0 +1,163 @@
---
type: theoretical
---
## Sets
A **set** is an unordered collection of unique objects (elements) with no duplicates.
### Notation
- $x \in A$: "x is an element of set A."
- $x \notin A$: "x is not an element of set A."
### Intervals of $\mathbb{R}$
An **interval** is a subset of $\mathbb{R}$ (the real numbers) defined by two endpoints $a$ and $b$. Any real number between $a$ and $b$ belongs to the interval.
### Cardinality
The **cardinality** of a set $S$ is the number of elements it contains, denoted $|S|$.
- **Finite Set**: A set with a finite number of elements. Example: $S = \{a, b, c\}$, $|S| = 3$.
- **Infinite Set**: A set that is not finite. Example: $\mathbb{N}, \mathbb{Z}, \mathbb{R}$.
- **Power Set**: For a finite set $S$, the cardinality of its power set $P(S)$ (set of all subsets of $S$) is $2^{|S|}$.
**Example**: For $S = \{a, b, c\}$, $P(S)$ contains $8 = 2^3$ subsets.
---
## Set Operations
Let $U$ be the universal set, and let $A$ and $B$ be subsets of $U$:
- **Union**: $A \cup B = \{x \mid x \in A \lor x \in B\}$
- **Intersection**: $A \cap B = \{x \mid x \in A \land x \in B\}$
- **Set Difference**: $A \setminus B = \{x \mid x \in A \land x \notin B\}$
- **Complement**: $\bar{A} = U \setminus A$, the set of all elements not in $A$.
---
## Proof Styles for Set Properties
### Annotated Linear Proof (ALP)
A **chain-of-equivalences proof** involves showing the equivalence of two sets step by step.
**Example**: Prove $A \cup (B \cup C) = (A \cup B) \cup C$.
- Start from $x \in A \cup (B \cup C)$ and simplify:
$$
x \in A \cup (B \cup C) \iff x \in A \lor (x \in B \lor x \in C) \iff (x \in A \lor x \in B) \lor x \in C \iff x \in (A \cup B) \cup C.
$$
- Conclude that the left-hand side equals the right-hand side.
---
## Sequences
A **sequence** is an ordered list of objects where repetition is allowed, and the order matters.
### Examples
1. Finite sequence: $1, 2, 3, 5, 7$ (length 5).
2. Infinite sequence: $0, 2, 4, 6, \ldots$ (continues indefinitely).
3. A sequence differs from a set: $1, 2, 3$ is not the same as $3, 2, 1$.
### Specifying Sequences
1. **Recursive Definition**:
- Example: $s_0 = 3$, $s_n = 2 \cdot s_{n-1} + 7$, defines $3, 13, 33, \ldots$.
2. **Explicit Definition**:
- Example: $s_n = n^2$ defines $0, 1, 4, 9, 16, \ldots$.
---
## Characteristic Function
The **characteristic function** of a set $A \subseteq U$ is a function $f_A : U \to \{0, 1\}$:
$$
f_A(x) =
\begin{cases}
1, & \text{if } x \in A, \\
0, & \text{if } x \notin A.
\end{cases}
$$
### Purpose
Characteristic functions represent sets mathematically and are useful for computations.
**Example**:
- $U = \{a, b, c, d, e\}$, $A = \{b, d\}$.
- Representation of $U$: $(1, 1, 1, 1, 1)$.
- Representation of $A$: $(0, 1, 0, 1, 0)$.
---
## Strings and Languages
### Formal Languages
1. **Alphabet ($\Sigma$)**: A non-empty set of symbols (letters).
2. **Word (String)**: A finite sequence of symbols from $\Sigma$.
- Example: $\Sigma = \{a, b\}$, string: $babab$.
3. **Empty String ($\epsilon$)**: A string with no symbols ($|\epsilon| = 0$).
4. **Language ($L$)**: A subset of $\Sigma^*$, the set of all possible strings over $\Sigma$.
Regex. Used for [Pattern matching](Pattern%20matching.md)
### Regular Sets and Expressions
1. $\alpha \cdot \beta$ (concatenation): Combine two sets of strings.
2. $\alpha | \beta$ (union): Combine strings from either set.
3. $\alpha^*$ (Kleene star): All strings formed by repeatedly concatenating elements of $\alpha$.
**Example**:
- Let $L$ correspond to $(a | b)^*(c | \epsilon)$.
- True/False:
- $abbac \in L$: True.
- $abccc \in L$: False.
- $abaa \in L$: False.
---
## Integers
### Primes
- **Prime Number**: A positive integer greater than 1 with only two divisors: 1 and itself.
- Examples: $2, 3, 5, 7$.
- **Euclid's Theorem**: There are infinitely many primes.
**Proof Sketch**:
1. Assume a finite list of primes $p_1, p_2, \ldots, p_n$.
2. Let $q = (p_1 \cdot p_2 \cdot \ldots \cdot p_n) + 1$.
3. If $q$ is prime, its not in the list.
4. If $q$ is not prime, it must be divisible by some prime not in the list.
### Prime Factorization
Every integer $n > 1$ can be uniquely expressed as a product of primes:
$$
n = p_1^{k_1} \cdot p_2^{k_2} \cdot \ldots \cdot p_s^{k_s}.
$$
**Examples**:
1. $60 = 2^2 \cdot 3 \cdot 5$.
2. $168 = 2^3 \cdot 3 \cdot 7$.
---
## Matrices and Boolean Operations
### Boolean Operations
- **OR ($\lor$)**: $a \lor b = \max(a, b)$.
- **AND ($\land$)**: $a \land b = \min(a, b)$.
**Example**: For $a, b \in \{0, 1\}$:
- $1 \lor 0 = 1$.
- $1 \land 0 = 0$.
---
## Mathematical Structures
### Arity and Notation
- **Arity**: The number of arguments an operation takes.
- **Unary**: Takes one argument (e.g., complement of a set).
- **Binary**: Takes two arguments (e.g., addition: $x + y$).
- **Nullary**: Takes no arguments (e.g., constant: $1$).
**Prefix/Infix/Postfix Notation**:
- **Prefix**: Operator first (e.g., $+ x y$).
- **Infix**: Operator between arguments (e.g., $x + y$).
- **Postfix**: Operator last (e.g., $x y +$).

View File

@ -0,0 +1,159 @@
---
type: theoretical
---
## Proving Equivalences
To prove that two statements $P$ and $Q$ are equivalent ($P \iff Q$):
1. ***Chain of Equivalences***:
Show that $P(x_1, \ldots, x_n) \iff \ldots \iff Q(x_1, \ldots, x_n)$, transforming $P$ into $Q$ step by step.
2. ***Bi-conditional***[^10] ***Decomposition***[^1]:
Use the fact that:
$$
(P \iff Q) \iff ((P \implies Q) \land (Q \implies P)).
$$
- Prove $P \implies Q$ (first direction).
- Prove $Q \implies P$ (second direction).
---
## Proving Universal Statements
To prove a statement of the form $\forall x\, P(x)$:
1. Proof by Exhaustion[^5]:
- If the domain of $x$ is finite, verify $P(x)$ for each possible value.
2. Proof by Universal Generalization[^6]:
- Let $c$ be an arbitrary element of the domain.
- Prove $P(c)$.
- Conclude that $\forall x\, P(x)$ holds.
**Example**:
- For all integers $n$, if $n$ is even, then $n^2$ is even.
- ***Proof***:
1. Let $n$ be an arbitrary integer.
2. Assume $n$ is even. Then $n = 2k$ for some integer $k$.
3. Compute $n^2 = (2k)^2 = 4k^2 = 2(2k^2)$, which is even.
---
## Proving Existential Statements
To prove a statement of the form $\exists x\, P(x)$:
1. Constructive Proof[^7]:
Find a specific $c$ such that $P(c)$ is true.
2. Non-constructive Proof[^8]:
- Assume $\forall x\, \neg P(x)$ (negation of existence).
- Derive a contradiction.
- Conclude that $\exists x\, P(x)$ must be true.
---
## Proof by Contraposition
Instead of proving $P \implies Q$, prove its contrapositive[^3]:
$$
\neg Q \implies \neg P
$$
**Example**:
- For all $n \in \mathbb{N}$, if $n^2$ is odd, then $n$ is odd.
- ***Proof***:
1. Prove the contrapositive: If $n$ is even, then $n^2$ is even.
2. Assume $n = 2k$. Then $n^2 = (2k)^2 = 4k^2 = 2(2k^2)$, which is even.
---
## Proof by Contradiction
To prove $P$:
1. Assume $\neg P$.
2. Derive a contradiction[^4].
3. Conclude that $P$ must be true.
**Example**:
- $\sqrt{2}$ is irrational.
- **Proof**:
1. Assume $\sqrt{2}$ is rational, so $\sqrt{2} = \frac{p}{q}$, where $p, q \in \mathbb{Z}$, $q \neq 0$, and $\frac{p}{q}$ is in lowest terms.
2. Square both sides: $2 = \frac{p^2}{q^2}$, so $2q^2 = p^2$.
3. $p^2$ is even, so $p$ is even ($p = 2k$).
4. Substitute $p = 2k$: $2q^2 = (2k)^2 = 4k^2$, so $q^2 = 2k^2$.
5. $q^2$ is even, so $q$ is even.
6. Contradiction: $p$ and $q$ cannot both be even since $\frac{p}{q}$ is in lowest terms.
7. Conclude $\sqrt{2}$ is irrational.
---
## Mathematical Induction
[^2]
![induction](induction.png)
To prove a statement of the form $\forall n \geq n_0, P(n)$:
1. *Base Case*:
Prove $P(n_0)$ is true.
2. *Inductive Hypothesis* - $IH$:
Assume $P(k)$ is true for some $k \geq n_0$.
3. *Inductive Step*:
Prove $P(k + 1)$ is true using $P(k)$.
**Example**:
- $1 + 2 + \dots + n = \frac{n(n + 1)}{2}$ for all $n \geq 1$.
- ***Proof***:
1. Base Case: For $n = 1$, LHS = $1$, RHS = $\frac{1(1 + 1)}{2} = 1$. Holds true.
2. $IH$: Assume $1 + 2 + \dots + k = \frac{k(k + 1)}{2}$.
3. Inductive Step: Show $1 + 2 + \dots + (k + 1) = \frac{(k + 1)(k + 2)}{2}$.
$$
\text{LHS} = (1 + 2 + \dots + k) + (k + 1) = \frac{k(k + 1)}{2} + (k + 1).
$$
Simplify:
$$
\frac{k(k + 1)}{2} + (k + 1) = \frac{k(k + 1) + 2(k + 1)}{2} = \frac{(k + 1)(k + 2)}{2}.
$$
Matches RHS.
---
## Strong[^9] Mathematical Induction
To prove $\forall n \geq n_0, P(n)$:
1. *Base Cases*:
Prove $P(n_0), P(n_0 + 1), \ldots, P(n_0 + m)$ are true.
2. *Inductive Hypothesis*:
Assume $P(i)$ is true for all $n_0 \leq i \leq k$.
3. *Inductive Step*:
Prove $P(k + 1)$ is true using the assumption $P(i)$ for all $i \leq k$.
**Example**:
- Every $n \geq 2$ can be factored into primes.
- **Proof**:
1. *Base Case*: $n = 2$ is a prime.
2. $IH$: Assume every $n \leq k$ can be factored into primes.
3. *Inductive Step*: For $n = k + 1$:
- If $k + 1$ is prime, done.
- If composite, $k + 1 = a \cdot b$, where $2 \leq a, b \leq k$.
- By hypothesis, $a$ and $b$ can be factored into primes.
- Combine the prime factors of $a$ and $b$ to get $k + 1$'s factorization.
[^1]: Breaking a complex problem into smaller, simpler parts to solve each one step by step
[^2]: Proof that works by showing it works for the smallest case, then assuming it works for one number and proving it works for the next
[^3]: Instead of directly proving "If A, then B," you prove "If not B, then not A," which means the same thing logically.
[^4]: A way of proving something is true by assuming it is false and showing this leads to a logical impossibility, which, as we know, really messes with everything.
[^5]: Checking every possible case individually to prove something is true for all of them.
[^6]: Showing something is true for all cases by proving it for an arbitrary or random example. Similar to formal proof for introducing the $\forall$ quantifier
[^7]: Directly finding an example to show something exists or is true.
[^8]: Proving something exists or is true without giving a specific example, usually by ruling out the possibility of it not being true.
[^9]: Like induction, but you assume everything is true up to a certain point to prove the next case
[^10]: A statement where both directions are true, like "A if and only if B," meaning A leads to B, and B leads to A.

View File

@ -0,0 +1,115 @@
---
type: theoretical
---
A recurrence relation is an equation that defines a sequence based on its earlier terms, along with initial values.
- The recurrence relation $a_n = a_{n-1} + 4$ with initial condition $a_1 = 3$ defines the sequence: $3, 7, 11, 15, \ldots$.
### Techniques for Finding Explicit Formulas
1. ***Backtracking*** involves repeatedly substituting the recurrence relation into itself until a pattern emerges.
- For the recurrence relation $a_n = a_{n-1} + 4$, we repeatedly substitute:
- $a_n = a_{n-1} + 4$
- $a_n = (a_{n-2} + 4) + 4 = a_{n-2} + 2 \cdot 4$
- $a_n = ((a_{n-3} + 4) + 4) + 4 = a_{n-3} + 3 \cdot 4$
- $\ldots$
- $a_n = a_{n-(n-1)} + (n-1) \cdot 4 = a_1 + (n-1) \cdot 4 = 3 + (n-1) \cdot 4$
- So, the explicit formula for the sequence is:
$$
a_n = 3 + (n-1) \cdot 4
$$
2. ***Characteristic Equation*** applies to linear homogeneous recurrence relations.
- A **LHR** relation of degree $k$ is of the form:
$$
s_n = a_1 s_{n-1} + a_2 s_{n-2} + \ldots + a_k s_{n-k},
$$
where $a_i \in \mathbb{R}$ are constants. [^1]
- The ***characteristic equation*** is:
$$
x^k - a_1 x^{k-1} - a_2 x^{k-2} - \ldots - a_k = 0
$$
- The roots of the characteristic equation determine the explicit formula for the sequence. The sources focus on degree-2 relations, but the method generalizes to any degree.
---
### Solving Linear Homogeneous Recurrence Relations of Degree 2
For $s_n = a s_{n-1} + b s_{n-2}$, the characteristic equation is $x^2 - ax - b = 0$. Let $r_1$ and $r_2$ be the roots:
1. **In case of distinct roots** ($r_1 \neq r_2$):
- The general solution is:
$$
s_n = c_1 r_1^n + c_2 r_2^n,
$$
where $c_1$ and $c_2$ are constants determined by initial conditions.
2. **In case of repeated roots** ($r_1 = r_2 = r$):
- The general solution is:
$$
s_n = r^n (c_1 + c_2 n),
$$
where $c_1$ and $c_2$ are constants determined by initial conditions. [^2]
---
## Example - Fibonacci Sequence
The Fibonacci sequence is defined as:
$$
f_n =
\begin{cases}
0, & \text{if } n = 0, \\
1, & \text{if } n = 1, \\
f_{n-1} + f_{n-2}, & \text{if } n \geq 2.
\end{cases}
$$
- The characteristic equation is:
$$
x^2 - x - 1 = 0
$$
- The roots are:
$$
r_1 = \frac{1 + \sqrt{5}}{2}, \quad r_2 = \frac{1 - \sqrt{5}}{2}.
$$
- Since $r_1 \neq r_2$, the explicit formula is:
$$
f_n = c_1 r_1^n + c_2 r_2^n.
$$
- Using the initial conditions:
- $f_0 = 0 = c_1 + c_2$
- $f_1 = 1 = c_1 \left(\frac{1 + \sqrt{5}}{2}\right) + c_2 \left(\frac{1 - \sqrt{5}}{2}\right)$
- Solving this system, we get:
$$
c_1 = \frac{1}{\sqrt{5}}, \quad c_2 = -\frac{1}{\sqrt{5}}.
$$
- Therefore, the explicit formula for the Fibonacci sequence is:
$$
f_n = \frac{1}{\sqrt{5}} \left(\frac{1 + \sqrt{5}}{2}\right)^n - \frac{1}{\sqrt{5}} \left(\frac{1 - \sqrt{5}}{2}\right)^n.
$$
---
## Verifying Explicit Formulas
The correctness of an explicit formula for a recurrence relation can be proven using ***strong mathematical induction***. For example, the explicit Fibonacci formula is verified by [Induction](Mathematical%20Proofs%20(Induction).md).
## Footnotes
[^1]: Linear homogeneous recurrence relations are equations where each term is a combination of earlier terms, with no added constants.
[^2]: Repeated roots in a characteristic equation require modifying the solution to include a term that grows linearly with $n$.

View File

@ -0,0 +1,184 @@
---
type: theoretical
---
## Partitions and Cartesian Products
### Cartesian Product
The *Cartesian product* of two sets $A$ and $B$ is the set of all ordered pairs where the first element is from $A$ and the second is from $B$:
$$
A \times B = \{ (a, b) \mid a \in A, \, b \in B \}
$$
- If $A = \{1, 2\}$ and $B = \{x, y\}$, then:
$$
A \times B = \{ (1, x), (1, y), (2, x), (2, y) \}
$$
[^1]: The Cartesian product creates pairs from all possible combinations of elements from two sets.
### Partitions
A partition of a set $S$ is a collection of non-empty, disjoint subsets $\{S_1, S_2, \dots, S_n\}$ such that:
- $S = S_1 \cup S_2 \cup \dots \cup S_n$
- $S_i \neq \emptyset$ for all $i$
- $S_i \cap S_j = \emptyset$ for all $i \neq j$
[^2]: Partitions divide a set into disjoint subsets that cover the entire set.
- A partition of $S = \{1, 2, 3, 4\}$ could be $\{\{1, 2\}, \{3, 4\}\}$.
---
## Binary Relations
A binary relation $R$ from set $A$ to set $B$ is a subset of the Cartesian product $A \times B$:
$$
R \subseteq A \times B
$$
- When $A = B$, $R$ is a relation on $A$.
### Representations of Relations
#### As [Sets](Mathematical%20Data%20Structures.md)
A relation can be represented as a set of ordered pairs.
- $R = \{ (1, 2), (2, 3), (3, 1) \}$
#### As [Matrices](Matrices.md)
For a finite set $A = \{a_1, a_2, \dots, a_n\}$, the relation matrix $M_R$ is an $n \times n$ matrix where:
$$
(M_R)_{ij} =
\begin{cases}
1, & \text{if } (a_i, a_j) \in R \\
0, & \text{otherwise}
\end{cases}
$$
#### As [Graphs](Graphs.md)
A digraph (directed graph) represents elements as vertices and relations as directed edges.
- For $R = \{ (1, 2), (2, 3) \}$, draw vertices for 1, 2, 3, with edges from 1 to 2 and 2 to 3.
---
## Properties of Relations
### Reflexive
A relation $R$ on set $A$ is *reflexive* if every element is related to itself:
$$
\forall a \in A, \, (a, a) \in R
$$
### Symmetric
$R$ is *symmetric* if:
$$
\forall a, b \in A, \, (a, b) \in R \implies (b, a) \in R
$$
### Antisymmetric
$R$ is *antisymmetric* if:
$$
\forall a, b \in A, \, (a, b) \in R \land (b, a) \in R \implies a = b
$$
### Transitive
$R$ is *transitive* if:
$$
\forall a, b, c \in A, \, (a, b) \in R \land (b, c) \in R \implies (a, c) \in R
$$
### Equivalence Relations
A relation that is *reflexive*, *symmetric*, and *transitive* is an ***equivalence*** relation.
- An equivalence relation partitions the set into equivalence classes.
[^3]: Equivalence relations naturally partition a set into equivalence classes, grouping related elements.
- For $a \in A$, **the equivalence class** $[a]$ is:
$$
[a] = \{ x \in A \mid (a, x) \in R \}
$$
- The set of all equivalence classes forms a partition of $A$.
---
## Operations on Relations
### Union
The union of two relations $R$ and $S$ on $A$:
$$
R \cup S = \{ (a, b) \mid (a, b) \in R \text{ or } (a, b) \in S \}
$$
Unions are used in [Kruskall Algorithm's Union-Find](Graph%20Algorithms.md)
### Intersection
The intersection of $R$ and $S$:
$$
R \cap S = \{ (a, b) \mid (a, b) \in R \text{ and } (a, b) \in S \}
$$
### Composition
The composition of relations $R$ and $S$ is:
$$
R \circ S = \{ (a, c) \mid \exists b \in A, \, (a, b) \in R \text{ and } (b, c) \in S \}
$$
---
## Algorithms
### Warshall's Algorithm
computes the transitive closure of a relation on a finite set.
- The smallest transitive relation $R^+$ that contains $R$ is called a **Transitive Closure**.
- Determines reachability in graphs; whether there is a path from one vertex to another.
#### Steps of Warshall's Algorithm
Given the adjacency matrix $M$ of a relation $R$ on set $A = \{a_1, a_2, \dots, a_n\}$:
1. Initialize $T^{(0)} = M$.
2. For $k = 1$ to $n$:
- For $i = 1$ to $n$:
- For $j = 1$ to $n$:
$$
T_{ij}^{(k)} = T_{ij}^{(k-1)} \lor (T_{ik}^{(k-1)} \land T_{kj}^{(k-1)})
$$
3. After $n$ iterations, $T^{(n)}$ is the transitive closure matrix.
---
[^1]: The Cartesian product creates pairs from all possible combinations of elements from two sets.
[^2]: Partitions divide a set into disjoint subsets that cover the entire set.
[^3]: Equivalence relations naturally partition a set into equivalence classes, grouping related elements.

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,49 @@
## Microcontroller: STM32G071RB
![](Pasted%20image%2020241206133007.png)
[Source](https://www.st.com/resource/en/datasheet/stm32g071rb.pdf)
- 32-bit ARM Cortex-M0+
- 64 MHz
- 128 KB of Flash memory
- 36KB of SRAM
- I2C, SPI, and UART,
- Hella low power
- $3.64
- 10.51 for a devboard (it has a built-in st-link)
## Telemetry: HopeRF RFM98W LoRa Module
![](Pasted%20image%2020241206134156.png)
- Low-power
- 0.3 kbps to 37.5 kbps and
- -148 dBm
- 10$
## Custom Flexible PCB
Why? Mostly because we can, but it also minimizes the weight and makes the whole thing more rigid and not susceptible to fall damage.
## Sensors
- BME280 - 5.50
- Pressure, Humidity, Temperature, Altitude
- ![](Pasted%20image%2020241206134207.png)
- Accelerometer and Gyroscope: MPU6050 6-axis IMU - €3,75
- ![](Pasted%20image%2020241206134213.png)
### Estimated** Costs
| Description | Quantity | Unit Price (EUR) | Source |
| ------------------------------------- | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| STM32G071RB | 1 | €3.64 | [STMicroelectronics](https://www.st.com/resource/en/datasheet/stm32g071rb.pdf) |
| 433 MHz Wireless Transceiver (RFM98W) | 1 | €10 | [TinyTronics](https://www.tinytronics.nl/en/communication-and-signals/wireless/lora/modules/hoperf-rfm98w-lora-module-433mhz) |
| Custom Flexible PCB (5 pcs) | 1 set | €30 (?) | [JLCPCB](https://jlcpcb.com/resources/flexible-pcb) |
| BME280 Sensor | 1 | €5.50 | [TinyTronics](https://www.tinytronics.nl/en/sensors/air/pressure/bme280-digital-barometer-pressure-and-humidity-sensor-module) |
| 6-axis IMU (MPU6050) | 1 | €8.50 | [TinyTronics](https://www.tinytronics.nl/en/sensors/acceleration-rotation/mpu-6050-accelerometer-and-gyroscope-3-axis-module-3.3v-5v) |
| Standard 9V Alkaline Battery | 1 | €2.00 | [Amazon](https://www.amazon.com/) |
| | | **€57.64** | |

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,39 @@
## Redstone computer
Do together with people - italic, show and explain in bold
1. **Basic redstone**
- Show and explain the basic components' functions and compare them to real-life electrical components (e.g., wires, switches, diodes).
2. *Logic gates*
- Build basic logic gates using redstone.
3. *Latches*
- simple latches with participants.
4. *Complex circuit design*
- design and assemble more complex circuits
5. **Combinational Logic Circuit Design**
- Build adder and multiplexer
6. _Storage circuits and memory_
- Build flip-flops and registers.
7. **Cache**
- how does retrieval work in memory
- the concept of cache with redstone
8. _Finite State Machines (FSM)_
- build a finite state machine
9. **The von Neumann Model of Computing**
- Idk about this one
10. **The data paths implementing the ISA of the LC-3 Processor**
- Build data paths
11. **Basic Input/Output (Polling); Memory Mapping**
- I/O redstone
12. _I/O by Interrupt_
- pressure plates or some shit
13. **Making the Leap from Assembly to Higher Level Languages**
- redstone -> command blocks?

View File

@ -0,0 +1,42 @@
## Summary
| Brief description | Difficulty (/10) | Time needed (h) | Estimated fun index (/10) | Manpower (# of ppl) |
| ----------------------------------------------------------------- | ---------------- | --------------- | ------------------------- | ------------------- |
| [[#Platrix]] | 5 | 5 | 9 | 1-2 |
| [[Committee market ideas#Spectrogram image \| Spectrogram image]] | 3 | 2 | 6 | 1 |
| [[Committee market ideas#Puck.js bop it \| Puck.js bop it]] | 7 | 5 | 7 | 2 |
| [[#Random shit]] | 1 | 2 | 4 | 1 |
---
## Description of ideas
### Random shit
I will bring my radios, MCUs and other shit like that. Also, I suggest we leave the sticker sheets uncut, so that we add **more** interactivity to our stand (by making people cut their own stickers).
### Puck.js bop it
Have a server, which could be any BT-enabled MCU, which is connected to an 8x8 matrix which shows the following instructions for the 2 players (2 pucks) involved:
![Puck it rules](puck_it.png)
The game ends if either of the following conditions are met:
- One of the players does the wrong move - the other one wins
- One of the players doesn't do the action on time (i.e. takes longer than a second to do it)
This is going to be really difficult considering:
- None of us has significant experience with bluetooth (except maybe serial communication but still)
- Even if we do manage to do it, bluetooth is quite unreliable and overall a pain to deal with
- We need multiple people to work on this
### Platrix
Working on this [already](https://github.com/CircuitReeRUG/platrix). r/place but irl and on one of these:
![Matrix](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcontent.instructables.com%2FFS8%2FQ93S%2FIN365TKF%2FFS8Q93SIN365TKF.jpg%3Fauto%3Dwebp%26fit%3Dbounds%26frame%3D1%26height%3D1024%26width%3D1024auto%3Dwebp%26frame%3D1%26height%3D300&f=1&nofb=1&ipt=dc2552496ead22cd67bd1d0d787e6c74bdd8e205be002a5dcdda481cd2f3fd2a&ipo=images)
### Spectrogram image
Have people upload images to a simple webserver (controlled by a raspberry pi/laptop) and display the images on a monitor/laptop. We can transmit with a hackrf/raspi and receive with an SDR stick.
Here's an example using [spectrum_painter](https://github.com/polygon/spectrum_painter)
![Example Spectrogram Image](https://github.com/polygon/spectrum_painter/raw/master/doc/smiley.jpg)

View File

@ -0,0 +1,14 @@
- Pin initialization should be left to the attendees
- Encoder is a bit weird
- Have people be able to write their keystrokes as an array of keys, define that and put into keymap
- Functions related to keys
- `sendKey(key)`
- `sendKeystroke(*keys, int len)`
- `getKey`
- OLED functions
- provide them the ssd1306.h file in a digestible way
- Encoder function
- `getEnc()`
-

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,15 @@
- klompen - wooden shoes
- traditionele kleding - traditional clothing
- verschillende - different
- anders - otherwise
- gelijk - similar
- geschiedenis - history
- Bulgaars traditionele kleding hebben meestal bloemen decoraties
- ze zijn gemaakt van hout en zijn leuk - they are made out of wood
Omdat alle Balkan-kleding op elkaar lijkt, kun je niet zeggen dat Roemeense kleding is de beste
heb je die?

View File

@ -0,0 +1,133 @@
## Recap
- Learned basic expressions
- Learned how to count (more or less)
- Learned how to ask and provide personal information
- Understood basic conversation (70%)
## Vocabulary additions
### Phrases
- Ik ben -> I am
- Ik studeen -> I study
- Ik woon in -> I reside in (country)
- Mijn naam is -> My name is
- Ik doe -> I am doing
- Hoe zeg je ... ? -> How do you say?
- Hoe spreek je ... **uit**? -> How do you pronounce ...?
- Herhaal = Repeat
- Leer = Learn
- Maak = Make
- Kijk = Watch
### Verbs
- luisteren -> to listen
- nazeggen -> to repeat
- lezen -> tor read
- oefenen -> to practice
- hebben -> to have
### Nouns
- bladzijde -> page
- klemtoon -> emphasis
### Numbers
| English | Dutch |
| ------------- | ------------------------------- |
| zero | nul (nuhl) |
| one | een (e-yn) |
| two | twee (tvey) |
| three | drie (dree) |
| four | vier (fvier) |
| five | vijf (faeif) |
| six | zes |
| seven | zeven (zayfe) |
| eight | acht |
| nine | negen (neiche) |
| ten | tien (teen) |
| *eleven* | *elf* |
| *twelve* | *twaalf* (tvaalv) |
| thir**teen** | der**tien** (dur-teen) |
| four**teen** | veer**tien** (vierteen) |
| fif**teen** | vijf**tien** (faif-teen) |
| six**teen** | zes**tien** (zes-teen) |
| seven**teen** | zeven**tien** (zayfenteen) |
| eigh**teen** | acht**tien** (acht-teen) |
| nine**teen** | negen**tien** (neichenteen) |
| twenty | twintig (tvintugh) |
| twenty-one | eenentwintig (e-yn en tvintugh) |
| thirty | dertig (dur-tugh) |
| fourty | veertig (fvier-tugh) |
| fifty | vijftig (faeif-tugh) |
| sixty | zestig (zes-tugh) |
| seventy | zeventig (zayven-tugh) |
| eighty | **tachtig** (tagh-tugh) |
| ninety | negentig (neighen-tuch) |
| hundred | honderd |
- 10-20 has the same logic as English
- When adding a digit to a 2-digit number (i.e. 21), you say the second digit first (i.e. one) and then the first (amount of 10s, i.e. 20).
- In English, 21 would be one and twenty if the same logic applied
- 21 - een en twintig
- 80 (**t**achtig) has an extra **t** in the beginning for some reason
## Personal pronouns
| Face | Pronoun |
| ------------ | ----------------- |
| 1 | ik |
| 2 (informal) | jij/je |
| 2 (formal) | u |
| 3 | hij, zij / ze,het |
| 1 | wij/we |
| 2 | jullie |
| 3 | zij/ze |
## Grammatical rules
### Formal "you"
- u -> formal
- jij/je -> informal
### Difference between *jij* & *je*
> Jij is used when an emphasis is being put on the word. You cant say "Ik ben Boyan, en je?", you should say "Ik ben Boyan, en jij?"
*jij* - is used for PARTICULAR emphasis on the person. you can always use the stressed form.
Same goes for *wij*(we) and *zij*(them).
These are called [[Linguistic Terms#Emphatic forms |Emphatic forms]].
### Conjugation rules
Whenever *jij/je* appears after the verb, the t gets dropped (if the verb doesn't usually end in a t).
### Conjugation of regular verbs
luisteren - listen
komen - come
| | luisteren | komen |
| ------------------ | --------- | ----- |
| ik | luister | kom |
| jij/je | luistert | komt |
| u | luistert | komt |
| hij, zij / ze, het | luistert | komt |
| wij / we | luisteren | komen |
| jullie | luisteren | komen |
| zij / ze | luisteren | komen |
### Conjugation of irregular verbs
heb - have
zijn - are
| | hebben | zijn |
| ------------------ | ---------- | ---- |
| ik | heb | ben |
| jij/je | hebt | bent |
| u | hebt/heeft | bent |
| hij, zij / ze, het | heeft | is |
| wij/we | hebben | zijn |
| jullie | hebben | zijn |
| zij/ze | hebben | zijn |
## Homework
### Words
- jullie - You/Yours (plural)
- docent - teacher

View File

@ -0,0 +1,71 @@
## Grammatical rules
### Comparison
> Grote -> Groter -> Grotst
### Possesion
- *van*
- Het boek is *van* Felicia.
- *'s*
- Het is Felicia *'s* boek.
- Possesive pronouns
- Het is *haar* boek.
### Sentence structure
![[Sentence Structure]]
### Possessive pronouns
| Posessive Pronouns (EN) | Personal Pronouns (NL) | Posessive Pronouns (NL) |
| ----------------------- | ---------------------- | --------------------------- |
| My | ik | Mijn |
| Yours | jij / ze | Jouw/je |
| Yours (formal) | u | Uw |
| His/Hers | hij, zij / ze | Zijn/Haar |
| Ours | wij / we | Ons/Onze |
| Yours (plural) | jullie | Jullie (je) if not stressed |
| Theirs | zij / ze | Hun |
#### *Ons* and *onze*
- *Ons* for neuter singular nouns - when *het* is the [[Linguistic Terms#Parts of speech|article]] in front
> *Ons* boek
- *Onze* is used for everything else (e.g. docent)
> *Onze* docent
### [[Linguistic Terms#Interrogative Pronouns|Interrogative pronouns]]
| English | Dutch |
| -------- | ------------------ |
| Who | Wie |
| How | Hoe |
| How many | Hoeveel |
| What | Wat |
| Where | Waar |
| Which | Welk(neuter)/Welke |
| When | Wanneer |
| Why | Waarom |
## Pronunciations
### [[Linguistic Terms#Emphatic forms |Emphasis]] on *een*
Whenever emphasized, *een* is pronounced eihn, while when not emphasized, it is pronounced as eun
## Vocabulary
- invullen -> to fill in (to "infull")
- er -> there
- dezelfde -> the same (coming from itself)
- betekenis -> meaning
- begrijpen -> to understand
- vragen -> to ask
- ander/en -> other(s)
- tellen -> to count
- blijven -> to stay ([when conjugated, v->f](https://www.verbix.com/webverbix/go.php?D1=24&T1=blijven))
-

View File

@ -0,0 +1,51 @@
## Vocabulary
| Dutch | English |
| ------------------ | ------------------------------------------------------------- |
| al | for |
| vind | find/like |
| gaan | to go |
| Hoe gaat het? | How's it going |
| ook | also |
| Ik heb geen... | I don't have... |
| Hoe oud ben jij | How old are you |
| Mag ik ... ? | Can I get a ... ? |
| elkaar | each other |
| afrekenen/betaalen | to pay |
| voorbeld | example |
| om | time [preposition](Linguistic%20Terms.md#Parts%20of%20speech) |
| eigenlijk | actually |
| bijna | almost |
## Het vs. De (definite articles)
1. **"De"** is used for:
- Almost all **plural nouns** (e.g., *de kinderen* - the children).
- **Masculine** and **feminine** singular nouns, which are the majority of Dutch nouns
- **Professions, people, animals, and plants**
- **Abstract concepts**
2. **"Het"** is used for:
- Singular **neuter** nouns
- **Diminutives** (nouns that are made smaller or cuter, usually ending in *-je*, *-tje*, *-etje*)
- Some **languages** and **sports**
### Common tips:
- About **80% of Dutch nouns** use **"de."**
- Most diminutives are **"het."**
- When in doubt, it is often a good idea to guess "de," though exceptions always exist.
## Een (indefinite article)
The indefinite article in Dutch, _"een"_, translates to "a" or "an" in English. It is used similarly to English when referring to something unspecific or when mentioning something for the first time.
Examples:
- Een man (a man)
- Een vrouw (a woman)
- Een boek (a book)
In Dutch, unlike English, the indefinite article does not change based on the noun's gender or whether it starts with a vowel or consonant.

View File

@ -0,0 +1,313 @@
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Lesson 1 - Hoofdstuk 1},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\title{Lesson 1 - Hoofdstuk 1}
\author{}
\date{}
\begin{document}
\maketitle
\hypertarget{recap}{%
\subsection{Recap}\label{recap}}
\begin{itemize}
\tightlist
\item
Learned basic expressions
\item
Learned how to count (more or less)
\item
Understood basic conversation (70\%)
\end{itemize}
\hypertarget{vocabulary-additions}{%
\subsection{Vocabulary additions}\label{vocabulary-additions}}
\hypertarget{phrases}{%
\subsubsection{Phrases}\label{phrases}}
\begin{itemize}
\tightlist
\item
Ik ben -\textgreater{} I am
\item
Ik studeen -\textgreater{} I study
\item
Ik woon in -\textgreater{} I reside in (country)
\item
Mijn naam is -\textgreater{} My name is
\item
Ik doe -\textgreater{} I am doing
\item
Hoe zeg je ... ? -\textgreater{} How do you say?
\item
Hoe spreek je ... \textbf{uit}? -\textgreater{} How do you pronounce
...?
\item
Herhaal = Repeat
\item
Leer = Learn
\item
Maak = Make
\item
Kijk = Watch
\end{itemize}
\hypertarget{verbs}{%
\subsubsection{Verbs}\label{verbs}}
\begin{itemize}
\tightlist
\item
luisteren -\textgreater{} to listen
\item
nazeggen -\textgreater{} to repeat
\item
lezen -\textgreater{} tor read
\item
oefenen -\textgreater{} to practice
\item
hebben -\textgreater{} to have
\end{itemize}
\hypertarget{nouns}{%
\subsubsection{Nouns}\label{nouns}}
\begin{itemize}
\tightlist
\item
bladzijde -\textgreater{} page
\item
klemtoon -\textgreater{} emphasis
\end{itemize}
\hypertarget{numbers}{%
\subsubsection{Numbers}\label{numbers}}
\begin{longtable}[]{@{}ll@{}}
\toprule
English & Dutch \\
\midrule
\endhead
zero & nul (nuhl) \\
one & een (e-yn) \\
two & twee (tvey) \\
three & drie (dree) \\
four & vier (fvier) \\
five & vijf (faeif) \\
six & zes \\
seven & zeven (zayfe) \\
eight & acht \\
nine & negen (neiche) \\
ten & tien (teen) \\
\emph{eleven} & \emph{elf} \\
\emph{twelve} & \emph{twaalf} (tvaalv) \\
thir\textbf{teen} & der\textbf{tien} (dur-teen) \\
four\textbf{teen} & veer\textbf{tien} (vierteen) \\
fif\textbf{teen} & vijf\textbf{tien} (faif-teen) \\
six\textbf{teen} & zes\textbf{tien} (zes-teen) \\
seven\textbf{teen} & zeven\textbf{tien} (zayfenteen) \\
eigh\textbf{teen} & acht\textbf{tien} (acht-teen) \\
nine\textbf{teen} & negen\textbf{tien} (neichenteen) \\
twenty & twintig (tvintugh) \\
twenty-one & eenentwintig (e-yn en tvintugh) \\
thirty & dertig (dur-tugh) \\
fourty & veertig (fvier-tugh) \\
fifty & vijftig (faeif-tugh) \\
sixty & zestig (zes-tugh) \\
seventy & zeventig (zayven-tugh) \\
eighty & \textbf{tachtig} (tagh-tugh) \\
ninety & negentig (neighen-tuch) \\
hundred & honderd \\
\bottomrule
\end{longtable}
\begin{itemize}
\tightlist
\item
10-20 has the same logic as English
\item
When adding a digit to a 2-digit number (i.e. 21), you say the second
digit first (i.e. one) and then the first (amount of 10s, i.e. 20).
\begin{itemize}
\tightlist
\item
In English, 21 would be one and twenty if the same logic applied
\item
21 - een en twintig
\end{itemize}
\item
80 (\textbf{t}achtig) has an extra \textbf{t} in the beginning for
some reason
\end{itemize}
\hypertarget{personal-pronouns}{%
\subsection{Personal pronouns}\label{personal-pronouns}}
\begin{longtable}[]{@{}ll@{}}
\toprule
Face & Pronoun \\
\midrule
\endhead
1 & ik \\
2 (informal) & jij/je \\
2 (formal) & u \\
3 & hij, zij / ze,het \\
1 & wij/we \\
2 & jullie \\
3 & zij/ze \\
\bottomrule
\end{longtable}
\hypertarget{grammatical-rules}{%
\subsection{Grammatical rules}\label{grammatical-rules}}
\hypertarget{formal-you}{%
\subsubsection{Formal "you"}\label{formal-you}}
\begin{itemize}
\tightlist
\item
u -\textgreater{} formal
\item
jij/je -\textgreater{} informal
\end{itemize}
\hypertarget{difference-between-jij-je}{%
\subsubsection{\texorpdfstring{Difference between \texttt{jij} \&
\texttt{je}}{Difference between jij \& je}}\label{difference-between-jij-je}}
\begin{quote}
Jij is used when an emphasis is being put on the word. You cant say "Ik
ben Boyan, en je?", you should say "Ik ben Boyan, en jij?"
\end{quote}
\texttt{jij} - is used for PARTICULAR emphasis on the person. you can
always use the stressed form.
Same goes for \texttt{wij}(we) and \texttt{zij}(them).
\hypertarget{conjugation-rules}{%
\subsubsection{Conjugation rules}\label{conjugation-rules}}
Whenever \texttt{jij/je} appears after the verb, the t gets dropped (if
the verb doesn't usually end in a t).
\hypertarget{conjugation-of-regular-verbs}{%
\subsubsection{Conjugation of regular
verbs}\label{conjugation-of-regular-verbs}}
luisteren - listen\\
komen - come
\begin{longtable}[]{@{}lll@{}}
\toprule
& luisteren & komen \\
\midrule
\endhead
ik & luister & kom \\
jij/je & luistert & komt \\
u & luistert & komt \\
hij, zij / ze, het & luistert & komt \\
wij / we & luisteren & komen \\
jullie & luisteren & komen \\
zij / ze & luisteren & komen \\
\bottomrule
\end{longtable}
\hypertarget{conjugation-of-irregular-verbs}{%
\subsubsection{Conjugation of irregular
verbs}\label{conjugation-of-irregular-verbs}}
heb - have\\
zijn - are
\begin{longtable}[]{@{}lll@{}}
\toprule
& hebben & zijn \\
\midrule
\endhead
ik & heb & ben \\
jij/je & hebt & bent \\
u & hebt/heeft & bent \\
hij, zij / ze, het & heeft & is \\
wij/we & hebben & zijn \\
jullie & hebben & zijn \\
zij/ze & hebben & zijn \\
\bottomrule
\end{longtable}
\hypertarget{homework}{%
\subsection{Homework}\label{homework}}
\hypertarget{words}{%
\subsubsection{Words}\label{words}}
\begin{itemize}
\tightlist
\item
jullie - You/Yours (plural)
\item
docent - teacher
\end{itemize}
\end{document}

View File

@ -0,0 +1,26 @@
## Emphatic forms
In English:
> He *doesn't* work very hard
as opposed to:
>He doesn't work *very* hard
Same with Dutch, but with the pronouns `jij`, `zij`, `wij`
## Gender
- masculinefeminineneuter in Dutch and English
![[Grammatical Gender.png]]
## Parts of speech
![[parts of speech.png]]
## Interrogative Pronouns
![[Interrogative pronouns.png]]
## Comparison
I.e. comparative and superlative adjectives
> Great -> Greater -> Greatest
Of in Nederlands "Large":
> Grote -> Groter -> Grots

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

View File

@ -0,0 +1,18 @@
---
date: 06.10.2024
---
### Summary
| Thing | Status | Todo | Deadline |
| ------------------------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------- |
| T-Shirts | Waiting for quotes | Check if better prices at t-shirt a la minut.<br>Ask if we can do a big batch (195 t-shirts) and a possible second order (20-25) | Wednesday |
| Trophy | Waiting for Andrew | 3D print, but try to get an actual trophy | ASAP |
| Stickers | Design? | BAPC - 400, FCG - 300 - 200EUR | Thursday |
| Mugs | Look into better prices | Full print - make design | Thursdayt |
| Ducks | Ready to order | Red, BAPC logo, 250 | ASAP |
| Balloons | Ready to order | Finalize design (add FCG logo lol) and orderrrr | ASAP |
| Sticks | Order | 600 sticks, aliexpress | ASAP |
| Badges | Look into | Personalized:<br>![](Pasted%20image%2020241006132647.png) | ASAP |
| Cool beers for companies | Look into | | ASAP |
| Goodie bags | Order | Perhaps try to get a lower price | ASAP |
### Talk to Rutger to make sure how to order

View File

@ -0,0 +1,7 @@
## Prelims
No fancy shit
## BAPC

View File

@ -0,0 +1,3 @@
### Tasks

View File

@ -0,0 +1,24 @@
- 110m, distance from centers EA->BB
### FSPL
$$
\begin{gather}
FSPL(dB) = 20\log_{10}(d) + 20\log_{10}(f)+20\log_{10}\left( \frac{4\pi}{c} \right) \\
FSPL = 20\log_{10}(0.1) + 20\log_{10}(446) + 36.44\\
\approx 66 dB
\end{gather}
$$
Loss just by transmitting (assuming 0 gain for both transmit and receive). Pretty bad.
## Wall attenuation
- Assuming 1 meter thickness per wall, estimate `15dB` loss, assuming max 4 walls
$$
66dB+ 60dB = 126dB
$$
## Total Loss
$$27 - 126 = -99dBm$$
## Conclusion
Assuming $-100dBm$ is the sensitivity bound, that shit is BARELY above it. Any interference would cause us to not hear each other.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -0,0 +1,92 @@
# Approach
## Routine aspirations
Inspired by [this post](https://old.reddit.com/r/PhysicsStudents/comments/1e289f4/what_should_be_my_daily_routine_to_be_a_physicist/ "https://old.reddit.com/r/PhysicsStudents/comments/1e289f4/what_should_be_my_daily_routine_to_be_a_physicist/"). Remember to take this step by step, keep going at it from different angles and you **will** succeed. Do **not** try to do this all at once, as you'll burn yourself out real fuckin fast.
1. Solid sleep schedule
- i.e. 8:00 - 11:00 with an hour or 2 wiggle room
- This implies **NO** voluntary nightly activities (playing games and minimize staying outside)
2. Regular workout routine
- Climbing ~2-3 hours, 1-2 days a week
- Gym (weights) ~1h, 1-2 days a week
3. **Eliminate** bad habits like doom-scrolling, brain-rotting, etc. Take your time and do this in a calculated manner. Seek to replace counter-productivity with pseudo-, then finally, actual productivity
4. Read scientific papers on the surface, from abstract straight to conclusion (~2h/week), read fully if interesting, of course
5. **Actively enjoy hobbies**. Needless to say, time for hobbies is necessary. Instead of mindlessly watching youtube videos/playing games, try to **pay attention to each hobby and treat it as such**.
6. Stick to **one** set of tutorials and labs and **go to each one**, no matter how easy they seem
7. Read at least 30 pages of your favorite book each night
8. Avoid ordering food as much as possible, try to aim for a protein-rich, balanced (as much as possible) diet. Keep taking your supplements each day.
9. Make sure to make time for socializing, whether that'd be with Marty or with friends
- When it comes to Marty, be clear and stern about your plans (this requires you to think them through)
![[Proposed Routine Plan.canvas|Proposed Routine Plan]]
## Proven studying tactics
For me of course.
- Print out mindmaps and other easily digestible forms of information, relevant to current material and stick them to the wall
- "Create" videos/explain the content to somebody else
- When reading through exercises and/or theory, draw over the pdf with notes while talking
- Do not procrastinate solving exercises, no matter how tedious they are
## Ideas
- Do not be afraid of deeply technical conversations. At the absolute _very_ least, if you have absolutely nothing to offer to the conversation, your jargon and perception gets an upgrade.
- Clean ur desk once in a while
- Schedule more social stuff like gatherings and dates with Marty
## Important concepts
> There are two things you can consider: **short time slot** and **long time** slots. Your short time slots can be spent on pleasure reading (articles, coding practice, reddit, google searches), and your long time slots should be devoted to HW and research. Things like preparing for your classes/appointments can be done in either depending on priority. Obviously, the two types of time-blocks will not always be disjointed in terms of the type of work you do with each one.
> "You need to study every moment of every day, sacrifice your life for ~~physics~~ CS, okay, bye".
> Politely reject that attitude. You want to study 6 days a week. Seven just isn't sustainable. Each day you study, you want to study ~~at least six hours~~ . This time needs to be productive. Focus on solving problems. When you read theory and math, don't just scan the words, pull out paper and writing implement and follow along.
> Once you hit this goal, if you don't feel like studying anymore, DON'T. Go relax. Explore your interests. Your central nervous system did a lot of work. It needs to recover.
> Prioritize your sleep. Staying up all night is a losing wager 9 / 10 times. You're not gaining any real time, you're just borrowing it from your future self.
# Course timeline
## Interesting Courses
| Name (link) | Code | Time |
| ------------------------- | -------- | ---- |
| Philosophy of Mathematics | FI213BK | 1a |
| Spectroscopy | WBCH044 | 2b |
| Mechanics and Relativity | WBMA060 | 2a |
| Theory of Science | PSBE2-05 | 2b |
| Cognitive Psychology | PSBE2-23 | 2b |
| Digital Signal Processing | WBPH067 | 2b |
## Block 1
- LinAlg - WBMA020
- Advanced Algorithms - WBCS052
- Advanced Programming - WBCS053
- Calculus 2 - WBCS054
- Algorithmic Programming Contests - WBCS045-05
## Block 2
- FuncProg - WBCS002
- WebEng - WBCS008
- DS - WBCS011
- Stats - WBCS049
- Algorithmic Programming Contests - WBCS045-05
## Block 3
- ==Software Engineering - WBCS017==
- Operating systems - WBCS023
- Intro to ML - WBCS032
- Software and Systems Security - ==WMCS034==
- Algorithmic Programming Contests - WBCS045-05
## Block 4
- ==Software Engineering - WBCS017==
- L&M - WBCS027
- Intro to CG - WBCS056
- Algorithmic Programming Contests - WBCS045-05
- Empty!!!

View File

@ -0,0 +1,38 @@
{
"nodes":[
{"id":"163ca037f71a0b6f","type":"group","x":-320,"y":115,"width":838,"height":865,"color":"4","label":"Health"},
{"id":"07a053d6dd1d68a0","type":"group","x":640,"y":334,"width":596,"height":427,"color":"6","label":"Productivity"},
{"id":"5159e3993f95efcb","type":"text","text":"Avoid bad habits (3)","x":-138,"y":135,"width":183,"height":60},
{"id":"3b1083b1e372d498","type":"text","text":"Reading (4, 7)","x":42,"y":417,"width":170,"height":60},
{"id":"f897f4ba690283db","type":"text","text":"Sleep Schedule Improvement (1)","x":-189,"y":600,"width":295,"height":50},
{"id":"3aa369dab5e52be1","type":"text","text":"Better Social (9)","x":-215,"y":900,"width":186,"height":60},
{"id":"8dbfb266e9ae4898","type":"text","text":"Physical health routine (2) becomes manageable ","x":-7,"y":900,"width":263,"height":60},
{"id":"1a3aafd43063deaf","type":"text","text":"Schedule better","x":-129,"y":740,"width":176,"height":60},
{"id":"c53e69212bf4751a","type":"text","text":"Eating better (8)","x":287,"y":800,"width":181,"height":60},
{"id":"2db72cbff0c7ee4d","type":"text","text":"Better communication and reliability","x":101,"y":711,"width":222,"height":60},
{"id":"a07ffd84eb97e076","type":"text","text":"Good habits","x":106,"y":264,"width":150,"height":60},
{"id":"6dc127fe4098cce8","type":"text","text":"Enjoy hobbies during day (5)","x":256,"y":417,"width":242,"height":60},
{"id":"0bc6527818df845c","type":"text","text":"Sticking to schedule (6)","x":660,"y":500,"width":250,"height":60},
{"id":"2b76b4366e7d7447","type":"text","text":"Consistency in terms of Uni","x":713,"y":354,"width":280,"height":60},
{"id":"7b69dd32a9ff908b","type":"text","text":"Using the same [[Plan#Proven studying tactics | Study tactics]]","x":933,"y":500,"width":283,"height":60},
{"id":"37abaca3fa89fb9b","type":"text","text":"Better mental and productivity","x":799,"y":681,"width":294,"height":60}
],
"edges":[
{"id":"e7314215770b1b5a","fromNode":"5159e3993f95efcb","fromSide":"bottom","toNode":"a07ffd84eb97e076","toSide":"top","label":"Replace with"},
{"id":"ea778f6b684828c5","fromNode":"a07ffd84eb97e076","fromSide":"bottom","toNode":"3b1083b1e372d498","toSide":"top"},
{"id":"3d552b06f8e838d2","fromNode":"a07ffd84eb97e076","fromSide":"bottom","toNode":"6dc127fe4098cce8","toSide":"top"},
{"id":"ab96f7d33eb891ce","fromNode":"3b1083b1e372d498","fromSide":"bottom","toNode":"f897f4ba690283db","toSide":"right"},
{"id":"c0ad3200c4953eec","fromNode":"6dc127fe4098cce8","fromSide":"bottom","toNode":"f897f4ba690283db","toSide":"right"},
{"id":"e5b241cb68304667","fromNode":"f897f4ba690283db","fromSide":"bottom","toNode":"1a3aafd43063deaf","toSide":"top"},
{"id":"b9c17ff043c9c20c","fromNode":"1a3aafd43063deaf","fromSide":"bottom","toNode":"3aa369dab5e52be1","toSide":"top"},
{"id":"bb5bfaec52770979","fromNode":"1a3aafd43063deaf","fromSide":"bottom","toNode":"8dbfb266e9ae4898","toSide":"top"},
{"id":"abbd6f42e11801dd","fromNode":"f897f4ba690283db","fromSide":"left","toNode":"5159e3993f95efcb","toSide":"left","label":"Feeds into"},
{"id":"a54109b27e452e8c","fromNode":"c53e69212bf4751a","fromSide":"bottom","toNode":"8dbfb266e9ae4898","toSide":"right"},
{"id":"14046f7578cefaf8","fromNode":"2b76b4366e7d7447","fromSide":"bottom","toNode":"0bc6527818df845c","toSide":"top"},
{"id":"f3acc398f229e47b","fromNode":"2b76b4366e7d7447","fromSide":"bottom","toNode":"7b69dd32a9ff908b","toSide":"top"},
{"id":"cf8880dfe4e23cf4","fromNode":"0bc6527818df845c","fromSide":"bottom","toNode":"37abaca3fa89fb9b","toSide":"top"},
{"id":"74f1bc2742e8f761","fromNode":"7b69dd32a9ff908b","fromSide":"bottom","toNode":"37abaca3fa89fb9b","toSide":"top"},
{"id":"73a16c85641dc4ff","fromNode":"163ca037f71a0b6f","fromSide":"right","toNode":"07a053d6dd1d68a0","toSide":"left"},
{"id":"a5d14c192499b2f9","fromNode":"1a3aafd43063deaf","fromSide":"right","toNode":"2db72cbff0c7ee4d","toSide":"left"}
]
}

View File

@ -0,0 +1,41 @@
- What is the role of lectures vs tutorials in the course
- **Lectures introduce new material, while tutorials help students understand said material by doing exercises, reiterating, etc**.
- Which ice-break activity would you consider for your 1st session?
- **Pick a person at random, they say a category, everybody else has to say their favorite thing in that category (i.e. food, operating system, animal, etc.)**
- **Icebreakers are always awkward, so it's best to not rely on it. The true icebreaker is to break the awkwardness by acting unserious during it.**
- Select 1-2 objectives for the tutorial and answer the following questions: 
**Let's choose understanding graph algorithms as an objective.**
- What is the verb used in the objective?
- **Understanding**
- What is the meaning of the verb?-=What must a student actually need to do to achieve the learning objective 
- **They have to:**
- **Understand relations**
- **Grasp the visual representation of those relations - graphs**
- **Be able to trace the path of an algorithm (mentally)**
- What do you think students will struggle with the most?
- **Understanding the concept of an algorithm in the context of graphs**
- **Memorizing the algorithms**
- How can you divide the learning objective =problem in order to work on smaller parts at the time? What would you discuss first and what second to work on the given objective?
- **Understanding the use case of a graph, using a top-down exposition to the concept**
- **Learning to use specific notation to describe relations and then turn them into a graph, and vice versa**
- **Applying previously learned problem solving/programming skills on this newfound representation of data**
- **Assigning the terms onto simple algorithms**
- **Explain the benefits and advantages of more complex, yet optimized algorithms**
- Now, think about active learning methods
- How do the lectures given in the course prepare your students for tutorials? Will you use some active learning tools to recapture the information from the lectures? 
- **I would assume that the lectures arm them with a shaky understanding of the current subject. Lectures are usually fast-paced and people who are fully able to follow them usually don't need to go to tutorials :D.**
- **It would be great to explain the concepts again. Through rewording them, reinforce the knowledge of students who already grasp them and create an opportunity for the others to analyse them.**
- **Solving exercises (i.e. applying the concepts) is very beneficial in most courses.**
- What active learning tools do fit your learning objectives the most and why? For what would you like to use them during your tutorial?
- **Setting goals in the beginning of the session sets the tone and shows progress**
- **Having dialogues is beneficial for both parties involved. Sparks the curiosity of both TA and Student.**
- **Providing real world examples and analogies is crucial for the digestibility of the information provided.**
- **Group work on more complex problem is great for both the academic process as well as the social one**
- How will you monitor the progress of learning: you want to know how your students progress in the course. What active learning tool would you use for that?
- **I would encourage them to ask me questions about assignments, exams or quizzes, without revealing the answers of course.**
- **I'd ask them about their perceived most confusing part of the material and elaborate on that.**
- **Asking them directly should also do the trick, of course avoiding sounding judgmental**
- **Making yourself available outside of formal situations (being on whatsapp or when seen on campus) works wonders.**

View File

@ -0,0 +1,23 @@
### Roles of a TA
1. Managing the group
- Making sure everyone is included
- Individually approach people if necessary
2. Managing activities
- Dealing with the practicalities of teaching
3. Managing learning
- Preparing and presenting the information gathered about the subject
### Expectations
1. Because it makes people feel more comfortable with one another
2. Icebreaker is something that makes people feel engaged and comfortable - even through awkwardness.
3. Expectation towards the students:
- Relative interest
- Eagerness to learn
4. Expectations from the students:
- Punctuality
- Availability
- Being approachable

Some files were not shown because too many files have changed in this diff Show More