{"id":146,"date":"2015-12-10T15:41:57","date_gmt":"2015-12-10T06:41:57","guid":{"rendered":"http:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/?page_id=146"},"modified":"2015-12-11T15:54:55","modified_gmt":"2015-12-11T06:54:55","slug":"c%e8%a8%80%e8%aa%9e%e8%ac%9b%e5%ba%a7%e3%80%80%e7%ac%ac%ef%bc%98%e5%9b%9e","status":"publish","type":"page","link":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/?page_id=146","title":{"rendered":"C\u8a00\u8a9e\u8b1b\u5ea7\u3000\u7b2c\uff18\u56de"},"content":{"rendered":"<h2>\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\uff08written by Taku Nakahara\uff09<\/h2>\n<p>\u7b2c\uff18\u56de\u306f\u300c\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u300d\u3092\u3084\u308a\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>wikipedia\u306b\u3088\u308b\u3068<a href=\"https:\/\/ja.wikipedia.org\/wiki\/\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\" target=\"_blank\">\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0<\/a>\u3068\u306f\u3001<\/p>\n<blockquote><p>\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0 (algorithm) \u3068\u306f\u3001\u6570\u5b66\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u3001\u8a00\u8a9e\u5b66\u3001\u3042\u308b\u3044\u306f\u95a2\u9023\u3059\u308b\u5206\u91ce\u306b\u304a\u3044\u3066\u3001\u554f\u984c\u3092\u89e3\u304f\u305f\u3081\u306e\u624b\u9806\u3092\u5b9a\u5f0f\u5316\u3057\u305f\u5f62\u3067\u8868\u73fe\u3057\u305f\u3082\u306e\u3092\u8a00\u3046\u3002\u300c\u7b97\u6cd5\u300d\u3068\u8a33\u3055\u308c\u308b\u3053\u3068\u3082\u3042\u308b\u3002<\/p>\n<p>\u300c\u554f\u984c\u300d\u306f\u305d\u306e\u300c\u89e3\u300d\u3092\u6301\u3063\u3066\u3044\u308b\u304c\u3001\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u6b63\u3057\u304f\u305d\u306e\u89e3\u3092\u5f97\u308b\u305f\u3081\u306e\u5177\u4f53\u7684\u624b\u9806\u304a\u3088\u3073\u6839\u62e0\u3092\u4e0e\u3048\u308b\u3002\u3055\u3089\u306b\u591a\u304f\u306e\u5834\u5408\u306b\u304a\u3044\u3066\u52b9\u7387\u6027\u304c\u91cd\u8981\u3068\u306a\u308b\u3002<\/p>\n<p>\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u6307\u793a\u3059\u308b\u305f\u3081\u306e\uff08\u96fb\u5b50\uff09\u6587\u66f8\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u3044\u3046\u3002\u4eba\u9593\u3088\u308a\u901f\u304f\u5927\u91cf\u306b\u6b63\u3057\u3044\u7d50\u679c\u3092\u5c0e\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u304c\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u5f37\u307f\u3067\u3042\u308b\u304c\u3001\u305d\u306e\u305f\u3081\u306b\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u6b63\u3057\u304f\u52b9\u7387\u7684\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u57fa\u3065\u304f\u3053\u3068\u304c\u5fc5\u8981\u3067\u3042\u308b\u3002<\/p><\/blockquote>\n<p>\u3068\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u5b9a\u7fa9\u306b\u3042\u308b\u3088\u3046\u306b\u3042\u3089\u3086\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4f55\u3089\u304b\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u5b9f\u88c5\u3057\u305f\u3082\u306e\u3068\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u4e2d\u3067\u3082\u7279\u306b\u3088\u304f\u4f7f\u308f\u308c\u308b\u3082\u306e\u306b\u306f\u3001\u56f2\u7881\u306b\u304a\u3051\u308b\uff62\u5b9a\u77f3\uff63\u306b\u3042\u305f\u308b\u3088\u3046\u306a\u6709\u540d\u306a\u6307\u3057\u624b\u304c\u3042\u308a\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u3081\u3061\u3083\u304f\u3061\u3083\u306b\u4e26\u3093\u3060\u6570\u5b57\u306e\u914d\u5217\u3092\u9806\u756a\u306b\u4e26\u3079\u308b\u65b9\u6cd5\u3068\u304b\u3001\u4e71\u6570\u3092\u7528\u3044\u3066\u6570\u5024\u8a08\u7b97\u7684\u3092\u884c\u3046\u65b9\u6cd5\u3068\u304b\u3002\u3002\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u6211\u3005\u306e\u3088\u304f\u4f7f\u3046\u3068\u3053\u308d\u3067\u8a00\u3046\u3068\u3001blast\u3084clustalw\u306a\u3069\u306e\u30a2\u30e9\u30a4\u30f3\u30e1\u30f3\u30c8\u3092\u8a08\u7b97\u306e\u4e00\u90e8\u3082\u3057\u304f\u306f\u5168\u90e8\u3067\u884c\u3046\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u201ddynamic programming (DP)\u201d\u3068\u3044\u3046\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<blockquote><p>Nature Biotechnology  22, 909 - 910 (2004)<br \/>\ndoi : 10.1038\/nbt0704-909<br \/>\nWhat is dynamic programming?<br \/>\nSean R Eddy<br \/>\n<a href=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_2.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-148\" src=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_2-287x300.gif\" alt=\"fig8_2\" width=\"287\" height=\"300\" \/><\/a><\/p>\n<p>The filled dynamic programming matrix for two DNA sequences, x = TTCATA and y = TGCTCGTA, for a scoring system of +5 for a match, -2 for a mismatch and -6 for each insertion or deletion.<\/p>\n<p>The cells in the optimum path are shown in red. Arrowheads are 'traceback pointers,' indicating which of the three cases were optimal for reaching each cell. (Some cells can be reached by two or three different optimal paths of equal score: whenever two or more cases are equally optimal, dynamic programming implementations usually choose one case arbitrarily. In this example, though, the optimal path is unique.)\n<\/p><\/blockquote>\n<p>\u672c\u5f53\u306f\u3082\u3046\u4e00\u500b\u3001\u52a0\u7b97\u3057\u3066\u3044\u306a\u3044matrix\u304c\u3042\u308b\u3068\u3068\u3066\u3082\u8aac\u660e\u3057\u3084\u3059\u3044\u306e\u3067\u3059\u304c\u3001\u307e\u3042\u8208\u5473\u3092\u6301\u3063\u305f\u4eba\u306f\u3053\u306e\u6587\u732e\u3092\u3042\u305f\u3063\u305f\u308a\u3001\u914d\u5217\u89e3\u6790\u306e\u521d\u6b69\u304c\u8f09\u3063\u3066\u3044\u308b\u53c2\u8003\u66f8\u3067\u3082\u8aad\u3093\u3067\u307f\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u7c21\u5358\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u3044\u304f\u3064\u304b\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>\u30e2\u30f3\u30c6\u30ab\u30eb\u30ed\u6cd5\u3067\u5186\u5468\u7387\u03c0\u3092\u6c42\u3081\u308b<\/h2>\n<p>\u307e\u305a\u306f\u4e71\u6570\u3092\u7528\u3044\u3066\u5186\u5468\u7387\u3092\u6c42\u3081\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304b\u3089\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4e2d\u306b\u306f\u305f\u304f\u3055\u3093\u899a\u3048\u3066\u3044\u308b\u4eba\u3082\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<\/p>\n<pre>\u5186\u5468\u7387 \u2252 3.14159 26535 89793 23846 26433 83279 50288 \u2026\r\n<\/pre>\n<p>\u3067\u3059\u3002\u3053\u306e\u5024\u3092\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u3092\u7528\u3044\u3066\u3067\u304d\u308b\u3060\u3051\u6b63\u3057\u304f\u8a08\u7b97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4e71\u6570\u306b\u3064\u3044\u3066\u8efd\u304f\u8aac\u660e\u3057\u3066\u304a\u304f\u3068\u3001\u3053\u308c\u306f\u300c\u4f55\u306e\u898f\u5247\u6027\u3082\u306a\u304f\u3067\u305f\u3089\u3081\u306b\u767a\u751f\u3059\u308b\u6570\uff63\u3068\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002\u9069\u5f53\u306b\u601d\u3044\u3064\u3044\u305f\u6570\u3092\u3071\u3089\u3071\u3089\u4e26\u3079\u3066\u3044\u3051\u3070\u305d\u308c\u304c\u4e71\u6570\u306e\u30bb\u30c3\u30c8\u306b\u306a\u308b\u8a33\u3067\u3059\u304c\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u3082\u3053\u308c\u3068\u4f3c\u305f\u3088\u3046\u306a\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u306a\u306e\u3067\u3044\u3064\u304b\u306f\u524d\u306b\u8a00\u3063\u305f\u6570\u3092\u3082\u3046\u4e00\u56de\u8a00\u3063\u3066\u3057\u307e\u3063\u3066\u540c\u3058\u3053\u3068\u306e\u7e70\u308a\u8fd4\u3057\u306b\u306a\u308a\u307e\u3059\u3002\u3067\u304d\u308b\u3060\u3051\u4e00\u69d8\u306b\u3070\u3089\u3051\u305f\u4e71\u6570\u3092\u767a\u751f\u3055\u305b\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u3044\u308d\u3044\u308d\u3042\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u5b8c\u5168\u306a\u4e71\u6570\u3092\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u3067\u767a\u751f\u3055\u305b\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u304c\u4f5c\u308a\u51fa\u3057\u305f\u4e71\u6570\u306e\u3053\u3068\u3092\u300c\u7591\u4f3c\u4e71\u6570\uff63\u3068\u547c\u3076\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>C\u8a00\u8a9e\u3067\u306f\u4e71\u6570\u3092\u767a\u751f\u3055\u305b\u308b\u306b\u306f\u3001rand()\u3068\u3044\u3046\u95a2\u6570\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; light: true; title: ; notranslate\" title=\"\">\r\n #include \r\n int ransuu = rand();\r\n<\/pre>\n<p>\u3068\u3044\u3046\u4f7f\u3044\u65b9\u3092\u3057\u307e\u3059\u3002rand()\u3092\u3088\u3073\u3060\u3059\u30680~32767\u307e\u3067\u306e\u6574\u6570\u3092\u9069\u5f53\u306b\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u6e96\u5099\u306f\u3053\u308c\u304f\u3089\u3044\u306b\u3057\u3066\u3001\u4e0b\u306e\u3088\u3046\u306a1\/4\u306e\u5186\u3092\u8003\u3048\u307e\u3059\u3002\u534a\u5f84\u306f\uff11\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-149\" src=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_3-300x162.jpg\" alt=\"fig8_3\" width=\"300\" height=\"162\" srcset=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_3-300x162.jpg 300w, https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_3.jpg 517w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u3053\u306e\u306a\u304b\u306bx=(0~1), y=(0~1)\u306e\u4e71\u6570\u3092\u767a\u751f\u3055\u305b\u3066\u3001\u305d\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u70b9\u3092\u307d\u3064\u307d\u3064\u6253\u3063\u3066\u3044\u3063\u305f\u3068\u3057\u307e\u3059\u3002\u305d\u3046\u3059\u308b\u3068\u3001\u5168\u4f53\u306e\u9762\u7a4d\uff11\u3067\u3001\u5186\u306e\u4e2d\u306b\u5165\u308b\u78ba\u7acb\u306f\u03c0\/4\u306b\u306a\u308b\u306f\u305a\u3067\u3059\u306d\u3002\u5168\u90e8\u306e\u70b9\u306e\u6570\u3092N\u3001\u5186\u306e\u4e2d\u306b\u5165\u3063\u305f\u70b9\u306e\u6570\u3092I\u3068\u3059\u308b\u3068\u3001<\/p>\n<p><a href=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-150\" src=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_4.jpg\" alt=\"fig8_4\" width=\"104\" height=\"33\" \/><\/a><\/p>\n<p>\u306a\u306e\u3067<\/p>\n<p><a href=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-151\" src=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_5.jpg\" alt=\"fig8_5\" width=\"58\" height=\"38\" \/><\/a><\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u306d\u3002<\/p>\n<p>\u307e\u3068\u3081\u308b\u3068\u3001<\/p>\n<p>\u3053\u306e\u7bc4\u56f2\u306b\u9069\u5f53\u306b\u591a\u6570\u306e\u70b9(x,y)\u3092\u307d\u3064\u307d\u3064\u6253\u3064\u3002<br \/>\n\u5186\u306b\u5165\u3063\u305f\u3082\u306e(x<sup>2<\/sup>+y<sup>2<\/sup> &lt; 1\u306b\u306a\u3063\u305f\u70b9\uff09\u304c\u3044\u304f\u3064\u3042\u308b\u304b\u6570\u3048\u308b\u3002<br \/>\n\uff14\u00d7\uff08\u5186\u306b\u5165\u3063\u305f\u6570\uff09\u00f7\uff08\u6253\u3063\u305f\u70b9\u306e\u6570\uff09\u3092\u8a08\u7b97\u3059\u308b\u3068\u03c0\u304c\u308f\u304b\u308b\u3002<br \/>\n\u3068\u3044\u3046\u624b\u9806\u306b\u306a\u308a\u307e\u3059\u3002\u5b9f\u969b\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>(pi.c)<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\ndouble getPoint();\r\n\r\nint main(int argc, char *argv&#x5B;])\r\n{\r\n    int    N = atoi(argv&#x5B;1]);\r\n    int    I = 0;\r\n    int    i;\r\n    double x, y, pi;\r\n    double delta;\r\n \r\n    for (i = 0; i &lt; N; i++) {\r\n        x = getPoint();\r\n        y = getPoint();\r\n \r\n        printf(&quot;(%f,%f)\\t&quot;, x, y);\r\n \r\n        if ((x*x+y*y) &lt; 1) {\r\n            printf(&quot;It's in!\\n&quot;);\r\n            I++;\r\n        } else {\r\n            printf(&quot;Out!\\n&quot;);\r\n        }\r\n    }\r\n\r\n    pi = (double)4*I\/N;\r\n \r\n    delta = 3.141592653589793 - pi;\r\n \r\n    printf(&quot;%d\/%d were in the circle area.\\n&quot;, I, N);\r\n    printf(&quot;pi = %f\\n&quot;, pi);\r\n    printf(&quot;d = %f\\n&quot;, delta);\r\n\r\n    return 0;\r\n}\r\n\r\ndouble getPoint()\r\n{\r\n    double rnd = (double)rand();\r\n    double point = rnd\/RAND_MAX;\r\n    return point;\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u6642\u306b\u306f\u5f15\u6570\u3068\u3057\u3066\u3044\u304f\u3064\u70b9\u3092\u6253\u3064\u304b(N)\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u306e\u7d50\u679c\u3001\u03c0\u304c\u3044\u304f\u3064\u3068\u8a08\u7b97\u3055\u308c\u305f\u304b(pi = ...)\u3068\u3001\u305d\u306e\u5024\u304c\u65e2\u306b\u5206\u304b\u3063\u3066\u3044\u308b\u5186\u5468\u7387\u3068\u6bd4\u3079\u3066\u3069\u308c\u304f\u3089\u3044\u305a\u308c\u3066\u3044\u308b\u304b(d = ...)\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002N\u304c\u5927\u304d\u304f\u306a\u308b\u3068pi\u304c\u3088\u308a3.1415...\u306b\u8fd1\u3065\u3044\u3066d\u304c\u5c0f\u3055\u304f\u306a\u308b\u304c\u5206\u304b\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u4e71\u6570\u3092\u3082\u3061\u3044\u3066\u884c\u3046\u6570\u5024\u8a08\u7b97\u6cd5\u306e\u3053\u3068\u3092\u300c\u30e2\u30f3\u30c6\u30ab\u30eb\u30ed(MC)\u6cd5\u300d\u3068\u547c\u3073\u307e\u3059\u3002\u30bf\u30f3\u30d1\u30af\u8cea\u306e\u30c0\u30a4\u30ca\u30df\u30af\u30b9\u3092\u8a08\u7b97\u3059\u308b\u306e\u306b\u306f\u3088\u304f\u5206\u5b50\u52d5\u529b\u5b66\u6cd5(MD)\u304c\u7528\u3044\u3089\u308c\u307e\u3059\u304c\u3001MC\u3082\u5206\u5b50\u8a08\u7b97\u3067\u306f\u3088\u304f\u7528\u3044\u3089\u308c\u308b\u624b\u6cd5\u3067\u3059\u3002\u5206\u5b50\u8a08\u7b97\u306e\u5834\u5408\u3001\u3072\u3068\u3064\u524d\u306e\u72b6\u614b\u306b\u4f9d\u5b58\u3057\u3066\u6b21\u306e\u72b6\u614b\u304c\u6c7a\u307e\u308b\u30de\u30eb\u30b3\u30d5\u9396(MC)\u7684\u306a\u6027\u8cea\u3092\u6301\u3064\u306e\u3067MCMC(\u30de\u30eb\u30b3\u30d5\u30c1\u30a7\u30a4\u30f3\u30e2\u30f3\u30c6\u30ab\u30eb\u30ed)\u6cd5\u3068\u8a00\u3063\u305f\u308a\u3057\u307e\u3059\u3002\u3053\u306e\u4f9d\u5b58\u95a2\u4fc2\u306f\u30e1\u30c8\u30ed\u30dd\u30ea\u30b9\u306e\u57fa\u6e96\u306b\u5f93\u3044\u307e\u3059\u3002\u305d\u308c\u304c\u4f55\u304b\u306f\u81ea\u5206\u3067\u52c9\u5f37\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u30d0\u30d6\u30eb\u30bd\u30fc\u30c8<\/h2>\n<p>\u30bd\u30fc\u30c8(sort)\u3068\u306f\u4f55\u3089\u304b\u306e\u898f\u5247\u306b\u5f93\u3063\u3066\u30c7\u30fc\u30bf\u3092\u4e26\u3079\u66ff\u3048\u308b\u3053\u3068\u3067\u3059\u3002\u305f\u3068\u3048\u3070{4, 7, 2, 9}\u3068\u3044\u3046\u6574\u6570\u306e\u914d\u5217\u304c\u3042\u3063\u305f\u3068\u304d\u3001\u5c0f\u3055\u3044\u3082\u306e\u307b\u3069\u524d\u306b\u304f\u308b\u3068\u3044\u3046\u30eb\u30fc\u30eb\u3067\u30bd\u30fc\u30c8\uff08\u8981\u3059\u308b\u306b\u5c0f\u3055\u3044\u9806\u306b\u4e26\u3079\u308b\uff09\u3068\u3001{2, 4, 7, 9}\u306b\u306a\u308a\u307e\u3059\u306d\u3001\u307f\u305f\u3044\u306e\u304c\u30bd\u30fc\u30c8\u3067\u3059\u3002\u3053\u308c\u3092\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u4e0a\u3067\u5b9f\u73fe\u3059\u308b\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306f\u305f\u304f\u3055\u3093\u63d0\u6848\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u9055\u3044\u306f\u8a08\u7b97\u91cf\u3067\u3059\u3002\u3082\u3063\u3068\u3082\u5358\u7d14\u306a\u76f4\u63a5\u9078\u629e\u6cd5\u3068\u547c\u3070\u308c\u308b\u65b9\u6cd5\u306f\u3001n\u500b\u306e\u8981\u7d20\u3092\u3082\u3064\u914d\u5217\u3092\u4e26\u3079\u308b\u8a08\u7b97\u91cf\u306fn<sup>2<\/sup>\u306b\u6bd4\u4f8b\u3057\u307e\u3059\u3002\u305d\u308c\u304c\u6539\u826f\u3055\u308c\u305f\u65b9\u6cd5\uff08\u305f\u3068\u3048\u3070\u30af\u30a4\u30c3\u30af\u30bd\u30fc\u30c8\u3060\u3068\u304b\u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u3060\u3068\u304b\u306e\u65b9\u6cd5\uff09\u3060\u3068nlog<sub>2<\/sub>n\u306b\u6bd4\u4f8b\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u305f\u3068\u3048\u3070\uff11\uff10\uff10\u4e07\u500b\u306e\u8981\u7d20(10<sup>6<\/sup>)\u306e\u8981\u7d20\u3092\u4e26\u3073\u66ff\u3048\u308b\u3068\u304d\u3001\u9045\u3044\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0(O(n<sup>2<\/sup>))\u3060\u3068\u8a08\u7b97\u91cf\u304c10<sup>12<\/sup>\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u901f\u3044\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0(O(nlog<sub>2<\/sub>n))\u3060\u30682*10<sup>7<\/sup>\u3068\u306a\u308a\u3001\u9045\u3044\u306e\u3068\u6bd4\u3079\u308b\u3068\uff15\u4e07\u500d\u3082\u306f\u3084\u304f\u4e26\u3079\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3001\u4eca\u65e5\u3084\u3063\u3066\u307f\u308b\u306e\u306f\u7c21\u5358\u306a\u9045\u3044\u65b9\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3067\u3001\u30d0\u30d6\u30eb\u30bd\u30fc\u30c8\u3068\u547c\u3070\u308c\u307e\u3059\u3002\u4e0b\u306e\u56f3\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-152\" src=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_6-300x206.jpg\" alt=\"fig8_6\" width=\"300\" height=\"206\" srcset=\"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_6-300x206.jpg 300w, https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/wp-content\/uploads\/2015\/12\/fig8_6.jpg 612w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u3053\u308c\u306f{80, 50, 56, 30, 51, 70}\u3068\u3044\u3046\u6574\u6570\u306e\u914d\u5217\u304c\u3042\u3063\u305f\u6642\u306b\u30d0\u30d6\u30eb\u30bd\u30fc\u30c8\u304c\u5c0f\u3055\u3044\u9806\u306b\u4e26\u3079\u66ff\u3048\u308b\u69d8\u5b50\u3092\u6a21\u5f0f\u7684\u306b\u3042\u3089\u308f\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u30d1\u30b9\uff11\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u65b9\u6cd5\u306f\u4e0b\u306e\u65b9\u304b\u3089\u4e0a\u306b\u5411\u304b\u3063\u3066\u9032\u307f\u3001\u81ea\u5206\u306e\u4e00\u500b\u4e0a\u306e\u8981\u7d20\u3068\u6bd4\u8f03\u3057\u3066\u81ea\u5206\u306e\u65b9\u304c\u5c0f\u3055\u3044\u3068\u304d\u3001\u81ea\u5206\u306e\u65b9\u304c\u4e0a\u306b\u4e0a\u304c\u308b\u3068\u3044\u3046\u65b9\u6cd5\u3067\u3059\u3002\u307e\u305a\u300170\u306851\u3092\u6bd4\u8f03\u3057\u3066\u9806\u756a\u306fOK\u306a\u306e\u3067\u305d\u306e\u307e\u307e\u3067\u3059\u3002\u6b21\u306b51\u306830\u3092\u6bd4\u8f03\u3057\u3066\u3053\u308c\u3082\u5c0f\u3055\u3044\u65b9\u304c\u4e0a\u306a\u306e\u3067OK\u3067\u3059\u300230\u306856\u3092\u6bd4\u8f03\u3059\u308b\u306830\u306e\u65b9\u304c\u5c0f\u3055\u3044\u306e\u306b\u4e0b\u306b\u3044\u308b\u306e\u3067\u3053\u3053\u306f\u3072\u3063\u304f\u308a\u8fd4\u3057\u307e\u3059\u3002\u6b21\u306b30\u306850\u3092\u6bd4\u8f03\u3057\u3066\u3001\u3053\u308c\u308230\u306e\u65b9\u304c\u5c0f\u3055\u3044\u306e\u3067\u3072\u3063\u304f\u308a\u8fd4\u3057\u307e\u3059\u3002\u3055\u3089\u306b30\u306880\u3092\u6bd4\u8f03\u3057\u3001\u3053\u308c\u3082\u3072\u3063\u304f\u308a\u8fd4\u3057\u307e\u3059\u3002\u3053\u3046\u3044\u3046\u3053\u3068\u3092\u3084\u3063\u3066\u3044\u308b\u3068\u3001\u5c0f\u3055\u3044\u5024\u306e\u8981\u7d20\u304c\u3077\u304b\u3077\u304b\u4e0a\u306b\u4e0a\u304c\u3063\u3066\u3044\u304d\u307e\u3059\u3002\u3060\u304b\u3089\u30d0\u30d6\u30eb\u30bd\u30fc\u30c8\u3068\u8a00\u3046\u306e\u3067\u3059\u3002\u3067\u306f\u5b9f\u969b\u306bcoding\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>(bubbleSort.c)<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main(int argc, char *argv&#x5B;])\r\n{\r\n    \/*\r\n     *   prepare integer array\r\n     *\/\r\n    int i, j, tmp;\r\n    int N = argc-1;\r\n    int array&#x5B;N];\r\n    for (i = 0; i &lt; N; i++) {\r\n        array&#x5B;i] = atoi(argv&#x5B;i+1]);\r\n    }\r\n \r\n    \/*\r\n     *   bubble sort\r\n     *\/\r\n    for (i = 0; i &lt; N; i++) {\r\n        for (j = N-1;\u3000j &gt; i;\u3000j--)\u3000{\r\n            if (array&#x5B;j] &lt; array&#x5B;j-1]) {\r\n                \/* swap *\/\r\n                tmp = array&#x5B;j];\r\n                array&#x5B;j] = array&#x5B;j-1];\r\n                array&#x5B;j-1] = tmp;\r\n            }\r\n        }\r\n    }\r\n \r\n    \/*\r\n     *   show results\r\n     *\/\r\n    for (i = 0; i &lt; N; i++) {\r\n        printf(&quot;%d &quot;, array&#x5B;i]);\r\n    }\r\n    printf(&quot;\\n&quot;);\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u7d50\u679c\u306f\u5404\u81ea\u3067\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u3046\u3044\u3046\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u81ea\u5206\u3067\u66f8\u3051\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3001\u4f8b\u3048\u3070\u3072\u3068\u3064\u306e\u8981\u7d20\u306b\u8907\u6570\u306e\u5c5e\u6027\u304c\u3042\u308b\u3068\u304d\uff08\u30bf\u30f3\u30d1\u30af\u8cea\u306e\u8cea\u91cf\u3068\u7dcf\u96fb\u8377\u3068\u7cd6\u9396\u4fee\u98fe\u6570\u3068\u304b\uff09\u304c\u3042\u3063\u305f\u6642\u306b\u3001\u307e\u305a\u8cea\u91cf\u306e\u9806\u3092\u512a\u5148\u3057\u3066\u3001\u8cea\u91cf\u304c\u540c\u3058\u6642\u306b\u306f\u7dcf\u96fb\u8377\u3067\u52dd\u8ca0\u3092\u6c7a\u3081\u3066\u3001\u3060\u3051\u3069\u7cd6\u9396\u304c\u3042\u308b\u5834\u5408\u306b\u306f\u3001\u305d\u308c\u306f\u305d\u308c\u3060\u3051\u3067\u5225\u30e9\u30f3\u30ad\u30f3\u30b0\u306b\u3059\u308b\u3068\u304b\u3001\u305d\u3046\u3044\u3046\u7d30\u304b\u3044\u8a2d\u5b9a\u3067\u3044\u308d\u3093\u306a\u30c7\u30fc\u30bf\u3092\u30bd\u30fc\u30c8\u3067\u304d\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u65e5\u306f\u4e09\u3064\u306e\u6709\u540d\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u5b9f\u306f\u3053\u3046\u3044\u3063\u305f\u6709\u540d\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3092\u81ea\u5206\u81ea\u8eab\u3067\u5b9f\u88c5\u3057\u306a\u304d\u3083\u306a\u3089\u3093\u3068\u3044\u3046\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u3059\u3002\u4e16\u306e\u4e2d\u306b\u306f\u3088\u304f\u4f7f\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30e9\u30a4\u30d6\u30e9\u30ea\u3084\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u516c\u958b\u3057\u3066\u3044\u308b\u3082\u306e\u3082\u3088\u304f\u3042\u308b\u306e\u3067\u3001\u305d\u3046\u3044\u3063\u305f\u3082\u306e\u3092\u5229\u7528\u3059\u308c\u3070\u3088\u304f\u3042\u308b\u9762\u5012\u306a\u3053\u3068\u306f\u30b9\u30ad\u30c3\u30d7\u3067\u304d\u307e\u3059\u3002Bioinformatics\u7cfb\u3067\u8a00\u3048\u3070\u3001bioperl, biojava, bioruby, biopython\u306a\u3093\u304b\u306f\u6709\u540d\u3067\u3059\u3002\u305f\u3060\u3001\u3053\u3046\u3044\u3063\u305f\u5916\u90e8\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u983c\u308b\u306b\u3057\u3066\u3082\u4e2d\u3067\u3069\u3093\u306a\u8a08\u7b97\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u306e\u304b\u5168\u304f\u5206\u304b\u3063\u3066\u3044\u306a\u3044\u306e\u306f\u3088\u304f\u306a\u3044\u3067\u3059\u3002\u4eca\u5f8c\u3082\u3044\u308d\u3044\u308d\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3084\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5229\u7528\u3057\u3066\u7814\u7a76\u3092\u884c\u3063\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u305c\u3072\u4e2d\u3067\u3069\u3093\u306a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u306e\u304b\u610f\u8b58\u3057\u3066\u3001\u5206\u304b\u3089\u306a\u3051\u308c\u3070\u8abf\u3079\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\uff08written by Taku Nakahara\uff09 \u7b2c\uff18\u56de\u306f\u300c\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u300d\u3092\u3084\u308a\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 wikipedia\u306b\u3088\u308b\u3068\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u3068\u306f\u3001 \u30a2\u30eb\u30b4\u30ea\u30ba\u30e0 (algorithm) \u3068\u306f\u3001\u6570\u5b66\u3001\u30b3\u30f3\u30d4\u30e5\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":96,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"vkexunit_cta_each_option":"","footnotes":""},"class_list":["post-146","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/pages\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=146"}],"version-history":[{"count":7,"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/pages\/146\/revisions"}],"predecessor-version":[{"id":184,"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/pages\/146\/revisions\/184"}],"up":[{"embeddable":true,"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=\/wp\/v2\/pages\/96"}],"wp:attachment":[{"href":"https:\/\/b-lab.nagahama-i-bio.ac.jp\/~m_shionyu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}