{"id":236,"date":"2010-07-11T00:05:42","date_gmt":"2010-07-11T04:05:42","guid":{"rendered":"http:\/\/hw.minilinux.net\/?p=236"},"modified":"2010-07-12T16:50:02","modified_gmt":"2010-07-12T20:50:02","slug":"%e6%af%8f%e6%97%a55%e9%a2%98-0710","status":"publish","type":"post","link":"https:\/\/hw.minilinux.net\/?p=236","title":{"rendered":"\u6bcf\u65e55\u9898&#8211;0710"},"content":{"rendered":"<p>\u4eca\u5929\u8bf4\u4e00\u4e9bDP(Dynamic Programming)\u7684\u9898\u76ee<\/p>\n<p>\u6211\u5bf9DP\u7684\u7406\u89e3, \u5982\u679c\u4e00\u4e2a\u95ee\u9898\u53ef\u4ee5\u4eceoptimal substructure\u63a8\u51fa, \u90a3\u4e48\u5c31\u53ef\u4ee5\u8003\u8651\u7528DP\u505a, DP\u7684\u4f18\u70b9, \u6bd4\u8f83\u7b80\u5355\u76f4\u63a5\u597d\u7406\u89e3,<\/p>\n<p>\u6700\u96be\u7684\u90e8\u5206\u5e94\u8be5\u662f\u627e\u5230\u90a3\u4e2a\u9012\u63a8\u8868\u8fbe\u5f0f.<\/p>\n<p>1. LCS(longest common sequence)<br \/>\n\u7ed9\u51fa\u6570\u7ec4 a[M], b[N], \u627e\u51fa, \u4ed6\u4eec\u4e4b\u95f4\u6700\u957f\u7684common sequence, \u6bd4\u5982<br \/>\na = &#8220;apple is fashion&#8221;<br \/>\nb = &#8220;google is not evil&#8221;<\/p>\n<p>\u90a3\u4e48\u5f97\u5230\u7684\u8f93\u51fa\u7ed3\u679c\u5c31\u662f<\/p>\n<blockquote><p>The LCS number is 7<br \/>\n&#8220;le is n&#8221;<\/p><\/blockquote>\n<p>\u53ef\u89c1\u8fd9\u4e24\u53e5\u770b\u4e0a\u53bb\u6ca1\u6709\u4ec0\u4e48\u5173\u7cfb\u7684\u8bdd\u8fd8\u662f\u6709\u4e00\u5b9a\u8054\u7cfb\u7684, lol<\/p>\n<p>\u5982\u679c\u5b9a\u4e49 F(i, j) \u662fa[0]&#8230;.a[i], \u548c b[0]&#8230;b[j]\u4e4b\u95f4\u7684common sequence \u7684\u4e2a\u6570<\/p>\n<p>\u6240\u4ee5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hw.minilinux.net\/wp-content\/ql-cache\/quicklatex.com-24ad657b52cc419b72181f1a6eeacd5b_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#70;&#40;&#105;&#44;&#106;&#41;&#32;&#61;&#92;&#108;&#101;&#102;&#116;&#92;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#70;&#40;&#105;&#45;&#49;&#44;&#32;&#106;&#45;&#49;&#41;&#43;&#49;&#38;&#105;&#102;&#92;&#113;&#117;&#97;&#100;&#32;&#97;&#91;&#105;&#93;&#32;&#61;&#32;&#98;&#91;&#106;&#93;&#32;&#92;&#92;&#109;&#97;&#120;&#92;&#123;&#70;&#40;&#105;&#45;&#49;&#44;&#32;&#106;&#41;&#44;&#32;&#70;&#40;&#105;&#44;&#32;&#106;&#45;&#49;&#41;&#92;&#125;&#38;&#105;&#102;&#92;&#113;&#117;&#97;&#100;&#32;&#97;&#91;&#105;&#93;&#32;&#33;&#61;&#98;&#91;&#106;&#93;&#92;&#92;&#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#46;\" title=\"Rendered by QuickLaTeX.com\" height=\"43\" width=\"437\" style=\"vertical-align: -17px;\"\/><\/p>\n<p>\u5982\u679c\u4e24\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u5206\u522b\u662fLEN1, LEN2, \u90a3\u4e48\u65f6\u95f4\u590d\u6742\u5ea6\u662fO(LEN1*LEN2), \u7136\u540e\u8fd8\u9700\u8981O(LEN1*LEN2)\u7684\u7a7a\u95f4\u590d\u6742\u5ea6.<\/p>\n<p>2. \u64cd\u4f5c\u6b21\u6570\u95ee\u9898(operation)<\/p>\n<p>\u5982\u679c\u6709\u4e24\u4e2a\u5b57\u7b26\u4e32str1, str2, \u600e\u4e48\u7528\u6700\u5c11\u7684\u64cd\u4f5c\u8ba9str1 \u53d8\u6210 str2<\/p>\n<p>\u4f60\u53ef\u4ee5\u5229\u7528\u7684\u64cd\u4f5c\u6709 1. \u63d2\u5165(insert) 2. \u66ff\u6362(replace) 3. \u5220\u9664(delete)<\/p>\n<p>\u518d\u6b21\u5f00\u52a8\u8111\u7ecf, \u5982\u679c\u8bb0\u5f55 F(i, j) \u4e3astr1[0&#8230;i]\u53d8\u6210str2[0&#8230;.j]\u6240\u9700\u8981\u7684\u64cd\u4f5c\u7684\u6570\u76ee.<\/p>\n<p>\u90a3\u4e48\u5c31\u6709<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hw.minilinux.net\/wp-content\/ql-cache\/quicklatex.com-3ef26a5dad6ca0c53a2e4ea2bad2c642_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#70;&#40;&#105;&#44;&#106;&#41;&#32;&#61;&#92;&#108;&#101;&#102;&#116;&#92;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#70;&#40;&#105;&#45;&#49;&#44;&#32;&#106;&#45;&#49;&#41;&#38;&#105;&#102;&#92;&#113;&#117;&#97;&#100;&#32;&#115;&#116;&#114;&#49;&#91;&#105;&#93;&#32;&#61;&#32;&#115;&#116;&#114;&#50;&#91;&#106;&#93;&#32;&#92;&#92;&#109;&#105;&#110;&#92;&#108;&#101;&#102;&#116;&#92;&#123;&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#70;&#40;&#105;&#45;&#49;&#44;&#32;&#106;&#41;&#32;&#40;&#100;&#101;&#108;&#101;&#116;&#105;&#111;&#110;&#41;&#92;&#92;&#32;&#70;&#40;&#105;&#44;&#32;&#106;&#45;&#49;&#41;&#32;&#40;&#105;&#110;&#115;&#101;&#114;&#116;&#105;&#111;&#110;&#41;&#92;&#92;&#70;&#40;&#105;&#45;&#49;&#44;&#106;&#45;&#49;&#41;&#32;&#40;&#114;&#101;&#112;&#108;&#97;&#99;&#101;&#41;&#92;&#92;&#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#46;&#43;&#49;&#38;&#105;&#102;&#92;&#113;&#117;&#97;&#100;&#32;&#115;&#116;&#114;&#49;&#91;&#105;&#93;&#32;&#33;&#61;&#115;&#116;&#114;&#50;&#91;&#106;&#93;&#92;&#92;&#92;&#101;&#110;&#100;&#123;&#109;&#97;&#116;&#114;&#105;&#120;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#46;\" title=\"Rendered by QuickLaTeX.com\" height=\"87\" width=\"530\" style=\"vertical-align: -39px;\"\/><\/p>\n<p>\u65f6\u95f4\u590d\u6742\u5ea6\u662f O(LEN1*LEN2)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u8bf4\u4e00\u4e9bDP(Dynamic Programming)\u7684\u9898\u76ee \u6211\u5bf9DP\u7684\u7406\u89e3, \u5982\u679c\u4e00\u4e2a\u95ee\u9898\u53ef\u4ee5\u4eceoptimal substructure\u63a8\u51fa, \u90a3\u4e48\u5c31\u53ef\u4ee5\u8003\u8651\u7528DP\u505a, DP\u7684\u4f18\u70b9, \u6bd4\u8f83\u7b80\u5355\u76f4\u63a5\u597d\u7406\u89e3, \u6700\u96be\u7684\u90e8\u5206\u5e94\u8be5\u662f\u627e\u5230\u90a3\u4e2a\u9012\u63a8\u8868\u8fbe\u5f0f. 1. LCS(longest common sequence) \u7ed9\u51fa\u6570\u7ec4 a[M], b[N], \u627e\u51fa, \u4ed6\u4eec\u4e4b\u95f4\u6700\u957f\u7684common sequence, \u6bd4\u5982 a = &#8220;apple is fashion&#8221; b = &#8220;google is not evil&#8221; \u90a3\u4e48\u5f97\u5230\u7684\u8f93\u51fa\u7ed3\u679c\u5c31\u662f The LCS number is 7 &#8220;le is n&#8221; \u53ef\u89c1\u8fd9\u4e24\u53e5\u770b\u4e0a\u53bb\u6ca1\u6709\u4ec0\u4e48\u5173\u7cfb\u7684\u8bdd\u8fd8\u662f\u6709\u4e00\u5b9a\u8054\u7cfb\u7684, lol \u5982\u679c\u5b9a\u4e49 F(i, j) \u662fa[0]&#8230;.a[i], \u548c b[0]&#8230;b[j]\u4e4b\u95f4\u7684common sequence \u7684\u4e2a\u6570 \u6240\u4ee5 \u5982\u679c\u4e24\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6\u5206\u522b\u662fLEN1, LEN2, \u90a3\u4e48\u65f6\u95f4\u590d\u6742\u5ea6\u662fO(LEN1*LEN2), \u7136\u540e\u8fd8\u9700\u8981O(LEN1*LEN2)\u7684\u7a7a\u95f4\u590d\u6742\u5ea6. &hellip; <a href=\"https:\/\/hw.minilinux.net\/?p=236\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u6bcf\u65e55\u9898&#8211;0710&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=236"}],"version-history":[{"count":6,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions\/238"}],"wp:attachment":[{"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hw.minilinux.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}