You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
| 0-1 Knapsack| Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$?|
135
+
|[0-1 Knapsack](../dynamic_programming/knapsack.md)| Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$?|
136
136
| Subset Sum| Given $N$ integers and $T$, determine whether there exists a subset of the given set whose elements sum up to the $T$.|
137
-
| Longest Increasing Subsequence (LIS)| You are given an array containing $N$ integers. Your task is to determine the LIS in the array, i.e., a subsequence where every element is larger than the previous one.|
137
+
|[Longest Increasing Subsequence (LIS)](../dynamic_programming/longest_increasing_subsequence.md)| You are given an array containing $N$ integers. Your task is to determine the LIS in the array, i.e., a subsequence where every element is larger than the previous one.|
138
138
| Counting Paths in a 2D Array| Given $N$ and $M$, count all possible distinct paths from $(1,1)$ to $(N, M)$, where each step is either from $(i,j)$ to $(i+1,j)$ or $(i,j+1)$.|
139
139
| Longest Common Subsequence| You are given strings $s$ and $t$. Find the length of the longest string that is a subsequence of both $s$ and $t$.|
140
140
| Longest Path in a Directed Acyclic Graph (DAG)| Finding the longest path in Directed Acyclic Graph (DAG).|
@@ -143,7 +143,7 @@ One of the tricks to getting better at dynamic programming is to study some of t
143
143
| Edit Distance| The edit distance between two strings is the minimum number of operations required to transform one string into the other. Operations are["Add", "Remove", "Replace"]|
Copy file name to clipboardExpand all lines: src/geometry/enclosing-circle.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,19 +13,19 @@ Consider the following problem:
13
13
14
14
For each $p_i$, find whether it lies on the circumference of the minimum enclosing circle of $\{p_1,\dots,p_n\}$.
15
15
16
-
Here, by the minimum enclosing circle (MEC) we mean a circle with minimum possible radius that contains all the $n$p, inside the circle or on its boundary. This problem has a simple randomized solution that, on first glance, looks like it would run in $O(n^3)$, but actually works in $O(n)$ expected time.
16
+
Here, by the minimum enclosing circle (MEC) we mean a circle with minimum possible radius that contains all the $n$points, inside the circle or on its boundary. This problem has a simple randomized solution that, on first glance, looks like it would run in $O(n^3)$, but actually works in $O(n)$ expected time.
17
17
18
18
To better understand the reasoning below, we should immediately note that the solution to the problem is unique:
19
19
20
20
??? question "Why is the MEC unique?"
21
21
22
-
Consider the following setup: Let $r$ be the radius of the MEC. We draw a circle of radius $r$ around each of thep $p_1,\dots,p_n$. Geometrically, the centers of circles that have radius $r$ and cover all the points $p_1,\dots,p_n$ form the intersection of all $n$ circles.
22
+
Consider the following setup: Let $r$ be the radius of the MEC. We draw a circle of radius $r$ around each of thepoints $p_1,\dots,p_n$. Geometrically, the centers of circles that have radius $r$ and cover all the points $p_1,\dots,p_n$ form the intersection of all $n$ circles.
23
23
24
24
Now, if the intersection is just a single point, this already proves that it is unique. Otherwise, the intersection is a shape of non-zero area, so we can reduce $r$ by a tiny bit, and still have non-empty intersection, which contradicts the assumption that $r$ was the minimum possible radius of the enclosing circle.
25
25
26
26
With a similar logic, we can also show the uniqueness of the MEC if we additionally demand that it passes through a given specific point $p_i$ or two points $p_i$ and $p_j$ (it is also unique because its radius uniquely defines it).
27
27
28
-
Alternatively, we can also assume that there are two MECs, and then notice that their intersection (which containsp $p_1,\dots,p_n$ already) must have a smaller diameter than initial circles, and thus can be covered with a smaller circle.
28
+
Alternatively, we can also assume that there are two MECs, and then notice that their intersection (which containsthe points $p_1,\dots,p_n$ already) must have a smaller diameter than initial circles, and thus can be covered with a smaller circle.
Copy file name to clipboardExpand all lines: src/graph/bridge-searching.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Pick an arbitrary vertex of the graph $root$ and run [depth first search](depth-
22
22
23
23
Now we have to learn to check this fact for each vertex efficiently. We'll use "time of entry into node" computed by the depth first search.
24
24
25
-
So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store thenode withearliest entry time found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{tin}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree:
25
+
So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store the earliest entry time of the node found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{tin}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree: