Skip to content

Add links to dynamic programming articles already made #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/dynamic_programming/intro-to-dp.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ That's it. That's the basics of dynamic programming: Don't repeat work you've do
One of the tricks to getting better at dynamic programming is to study some of the classic examples.

## Classic Dynamic Programming Problems
| Name | Description/Example |
| Name | Description |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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$? |
| [0-1 Knapsack](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$? |
| Subset Sum | Given $N$ integers and $T$, determine whether there exists a subset of the given set whose elements sum up to the $T$. |
| Longest Increasing Subsequence | You are given an array containing $N$ integers. Your task is to determine the LCS in the array, i.e., LCS where every element is larger than the previous one. |
| [Longest increasing subsequence](../sequences/longest_increasing_subsequence.md) | You are given an array containing $N$ integers. Your task is to determine the LCS in the array, i.e., LCS where every element is larger than the previous one. |
| Counting all possible paths in a matrix. | 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)$. |
| 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$. |
| Longest Path in a Directed Acyclic Graph (DAG) | Finding the longest path in Directed Acyclic Graph (DAG). |
Expand All @@ -143,7 +143,7 @@ One of the tricks to getting better at dynamic programming is to study some of t
| 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"] |

## Related Topics
* Bitmask Dynamic Programming
* [Bitmask Dynamic Programming](profile-dynamics.md)
* Digit Dynamic Programming
* Dynamic Programming on Trees

Expand Down
4 changes: 2 additions & 2 deletions src/graph/strongly-connected-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void dfs(int v, vector<vector<int>> const& adj, vector<int> &output) {
// input: adj -- adjacency list of G
// output: components -- the strongy connected components in G
// output: adj_cond -- adjacency list of G^SCC (by root vertices)
void strongy_connected_components(vector<vector<int>> const& adj,
void strongly_connected_components(vector<vector<int>> const& adj,
vector<vector<int>> &components,
vector<vector<int>> &adj_cond) {
int n = adj.size();
Expand Down Expand Up @@ -117,7 +117,7 @@ void strongy_connected_components(vector<vector<int>> const& adj,
// second series of depth first searches
for (auto v : order)
if (!visited[v]) {
std::vector<int> component;
vector<int> component;
dfs(v, adj_rev, component);
sort(component.begin(), component.end());
components.push_back(component);
Expand Down
1 change: 1 addition & 0 deletions src/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ search:
- Dynamic Programming
- [Introduction to Dynamic Programming](dynamic_programming/intro-to-dp.md)
- [Knapsack Problem](dynamic_programming/knapsack.md)
- [Longest increasing subsequence](sequences/longest_increasing_subsequence.md)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that the way navigation works currently, each article is assumed to belong to exactly one (sub)section. In particular, this article already appears in "Miscellaneous -> Sequences" section. I don't have a strong opinion on which section it's better to keep it, but if you want to move it here, you should also change the file directory to dynamic_programming and create a redirect from the old link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the lack of articles in the dp section it probably should be moved as people care more about dp than random sequences (heck, my intro to dp article ranks 6 on duckduckgo right now!). I'll probably look into it.

- DP optimizations
- [Divide and Conquer DP](dynamic_programming/divide-and-conquer-dp.md)
- [Knuth's Optimization](dynamic_programming/knuth-optimization.md)
Expand Down
2 changes: 1 addition & 1 deletion test/test_strongly_connected_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main() {
adj[9].push_back(4);

vector<vector<int>> components, adj_scc;
strongy_connected_components(adj, components, adj_scc);
strongly_connected_components(adj, components, adj_scc);

// sort things to make it easier to verify
sort(components.begin(), components.end(),
Expand Down
Loading