Skip to content

Commit

Permalink
feat: update articles
Browse files Browse the repository at this point in the history
  • Loading branch information
wx-chevalier committed Jul 12, 2019
1 parent 0191f68 commit 95fb735
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 19 deletions.
2 changes: 1 addition & 1 deletion 数据结构与算法/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
> “Bad programmers worry about the code. Good programmers worry about data structures and their relationships.”
> — Linus Torvalds, creator of Linux
数据结构与算法的思想适用于任何语言,开发者也应当能够使用他们日常工作的语言来快速实现常见的数据结构或者算法。本系列文章包含了 Java, JavaScript, Go, Rust, Python 等不同的语言实现,分别对应着 `*.md, *.js.md, *.go.md, *.rs.md, *.py.md` 等不同的后缀文件名。本系列文章对应的算法实现参考 [algorithm-snippets](https://github.com/wx-chevalier/algorithm-snippets)
数据结构与算法的思想适用于任何语言,开发者也应当能够使用他们日常工作的语言来快速实现常见的数据结构或者算法。本系列文章包含了 Java, JavaScript, Go, Rust, Python 等不同的语言实现,请参考关联仓库 [algorithm-snippets](https://github.com/wx-chevalier/algorithm-snippets) 浏览

# Nav | 导航

Expand Down
1 change: 0 additions & 1 deletion 数据结构与算法/meta.yml

This file was deleted.

11 changes: 0 additions & 11 deletions 数据结构与算法/动态规划/背包问题.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# 背包问题

# 0-1 背包

01 背包的状态转换方程 `f[i,j] = Max{ f[i-1,j-Wi]+Pi( j >= Wi ), f[i-1,j] }`

(1) V(i,0)=V(0,j)=0 (2) V(i,j)=V(i-1,j) j<wi\
V(i,j)=max{V(i-1,j) ,V(i-1,j-wi)+vi) } j>wi (1) 式表明:如果第 i 个物品的重量大于背包的容量,则装人前 i 个物品得到的最大价值和装入前 i-1 个物品得到的最大价是相同的,即物品 i 不能装入 背包;第 (2) 个式子表明 : 如果第 i 个物品的重量小于背包的容量,则会有一下两种情况:(a) 如果把第 i 个物品装入背包,则背包物品的价值等于第 i-1 个 物品装入容量位 j-wi 的背包中的价值加上第 i 个物品的价值 vi; (b) 如果第 i 个物品没有装入背包,则背包中物品价值就等于把前 i-1 个物品装入容量为 j 的背包中所取得的价值。显然,取二者中价值最大的作为把前 i 个物品装入容量为 j 的背包中的最优解。

有编号分别为 a,b,c,d,e 的五件物品,它们的重量分别是 2,2,6,5,4,它们的价值分别是 6,3,5,4,6,现在给你个承重为 10 的背包,如何让背包里装入的物品具有最大的价值总和? | name | weight | value | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | | ---- | ------ | ----- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | | a | 2 | 6 | 0 | 6 | 6 | 9 | 9 | 12 | 12 | 15 | 15 | 15 | | b | 2 | 3 | 0 | 3 | 3 | 6 | 6 | 9 | 9 | 9 | 10 | 11 | | c | 6 | 5 | 0 | 0 | 0 | 6 | 6 | 6 | 6 | 6 | 10 | 11 | | d | 5 | 4 | 0 | 0 | 0 | 6 | 6 | 6 | 6 | 6 | 10 | 10 | | e | 4 | 6 | 0 | 0 | 0 | 6 | 6 | 6 | 6 | 6 | 6 | 6 |

![](http://images.cnitblog.com/blog/454792/201303/23110036-37762cbba6484ef3a7e3570062b099c9.png)

f[i,j]表示在前 i 件物品中选择若干件放在承重为 j 的背包中,可以取得的最大价值。 Pi 表示第 i 件物品的价值。决策:为了背包中物品总价值最大化,第 i 件物品应该放入背包中吗 ?
1 change: 0 additions & 1 deletion 数据结构与算法/哈希表/meta.yml

This file was deleted.

Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions 数据结构与算法/查找树/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
- B/B+: 运用在 file system database 这类持续存储结构,同样能保持 lon(n) 的插入与查询,也需要额外的平衡调节。像 mysql 的数据库定义是可以指定 B+ 索引还是 hash 索引。

- Tire: 大都用在 word 的匹配,但单纯的 trie 内存消耗很大,建 trie 树也需要些时间,通常用在带词典的机械分词,jieba 分词就是建立在 trie 上匹配的,trie 有其他变体可以压缩空间,像 double array trie 这类比较老且经典的压缩方法,也有其他比较新的压缩方式,看论文时有看过,没自己实现过所以不断言了,其实面对多模匹配 trie 没有其变体 aho-corasick 来得理想,另外 aho-corasick 也是可以用巧妙的方法来进行压缩空间,这里不再展开,毕竟手机码字,同时想基数树与其也类似,在 nginx 上有应用,说到 aho-corasick 其实早期的入侵检测工具 snort 也有应用实现,但如今改成 wu-menber 了,具体记不清了,其实 trie 还是挺有用的,Tengine 也用 trie 实现了了匹配模块。但要是用在大量单词的匹配上确实吃内存。

- [数据结构与算法/查找树 https://url.wx-coder.cn/9PnzG ](https://url.wx-coder.cn/9PnzG)
5 changes: 0 additions & 5 deletions 数据结构与算法/查找树/README的副本.md

This file was deleted.

0 comments on commit 95fb735

Please sign in to comment.