• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            bon

              C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              46 Posts :: 0 Stories :: 12 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(2)

            我參與的團(tuán)隊(duì)

            搜索

            •  

            最新評(píng)論

            • 1.?re: pku 1861
            • 評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
            • --edward2
            • 2.?re: pku 3349
            • 大哥超時(shí) 勒
            • --sum
            • 3.?re: pku 3070
            • 學(xué)習(xí)下,哇哈哈
            • --bear
            • 4.?re: poj 3340
            • 不用DFS的,直接有數(shù)學(xué)規(guī)律的,找出滿足條件的最小的數(shù)就可以了
            • --czcomt
            • 5.?re: pku 3070
            • 方法不錯(cuò)額~~~
            • --Zeor

            閱讀排行榜

            評(píng)論排行榜

            2009年4月30日 #

            Recently, I began to peruse the CLRS (Introduction to Algorithms).

            Now I would like to scan all basic algorithms, especially sorting and searching.

            Let me first present a classic sorting algorithm - merge sort. Here is my code. Before I reach here, some mistakes are made, thus I note these "pitfalls" in the code

            #include <stdlib.h>
            #include <stdio.h>
            #define MAX 1e9    // the biggest possible value of a int number is 2^31 - 1 which is approximately 10^9
            #define SIZE 10

            int *a;
            int *b;
            int *c;

            // merge [p, q] and [q+1, r], where within each range number are sorted
            void merge(int p, int q, int r)
            {
                int k;
                int length = r - p +1;            // the length the range to be merge
                for (k = 0; k < q - p + 1; k++) {
                    b[k] = a[p + k];             // copy number in a[p, q] to b
                }
                b[k] = MAX;             // b[k] = MAX, not b[k+1]=MAX
                for (k = 0; k < r - q; k++) {
                    c[k] = a[q + 1 + k];             // copy number in a[q+1, r] to c
                }
                c[k] = MAX;             // c[k] = MAX, not c[k+1]=MAX

                /* BEGIN merging */
                int i = 0;
                int j = 0;
                for (k=0;k<length;k++) {             // do exactly length times of copy
                    if (b[i] < c[j]) {
                        a[p + k] = b[i++];          // be careful! a[p, r] is a whole range now, and watch out the base "p"
                    } else {
                        a[p + k] = c[j++];
                    }
                }
            }

            void merge_sort(int l, int u)
            {
                if (l == u) return;             // when to stop recursion? only one number needs no sorting
                int m = (l + u)/2;
                merge_sort(l, m);
                merge_sort(m + 1, u);
                merge(l, m, u);
            }

            int main()
            {
                a = (int*)malloc(SIZE * sizeof(int));
                b = (int*)malloc(SIZE * sizeof(int));          // cache, avoid many "malloc" in the merge function
                c = (int*)malloc(SIZE * sizeof(int));          // this trick is from "Programming Pearls"
                int i;
                for (i = 0; i < SIZE; i++) {
                    a[i] = SIZE - i;
                }
                merge_sort(0, SIZE - 1);                    // watch out the range
                for (i = 0; i < SIZE; i++) {
                    printf("%d\n", a[i]);
                }
                return 1;
            }

            posted @ 2009-04-30 13:57 bon 閱讀(257) | 評(píng)論 (0)編輯 收藏

            2008年7月31日 #

                 摘要: 未完  閱讀全文
            posted @ 2008-07-31 10:51 bon 閱讀(300) | 評(píng)論 (0)編輯 收藏

            2008年7月28日 #

                 摘要: 水題  閱讀全文
            posted @ 2008-07-28 16:48 bon 閱讀(482) | 評(píng)論 (0)編輯 收藏

            2008年7月25日 #

                 摘要: 詳細(xì)介紹KMP算法以及POJ上的一道題目  閱讀全文
            posted @ 2008-07-25 11:45 bon 閱讀(398) | 評(píng)論 (0)編輯 收藏

            2008年7月9日 #

                 摘要: kddcup08 (1)  閱讀全文
            posted @ 2008-07-09 09:55 bon 閱讀(716) | 評(píng)論 (0)編輯 收藏

            2008年6月29日 #

            最近在Wei的指導(dǎo)下,跟顯露參加了KDDCUP08的數(shù)據(jù)挖掘比賽。在這次比賽中的數(shù)據(jù)處理、算法以及其它的收獲,會(huì)以連載的方式發(fā)出來,敬請(qǐng)各位關(guān)注。
            posted @ 2008-06-29 10:52 bon 閱讀(1182) | 評(píng)論 (1)編輯 收藏

            2008年6月9日 #

                 摘要: 解題報(bào)告 rather tricky  閱讀全文
            posted @ 2008-06-09 15:29 bon 閱讀(605) | 評(píng)論 (0)編輯 收藏

            2008年5月27日 #

                 摘要: pku 1936 解題報(bào)告+LCS的理解  閱讀全文
            posted @ 2008-05-27 15:46 bon 閱讀(786) | 評(píng)論 (0)編輯 收藏

            2008年5月24日 #

                 摘要: 遞歸 樹的深度 左兒子右兄弟  閱讀全文
            posted @ 2008-05-24 20:34 bon 閱讀(509) | 評(píng)論 (0)編輯 收藏

                 摘要: hash表  閱讀全文
            posted @ 2008-05-24 11:34 bon 閱讀(1085) | 評(píng)論 (1)編輯 收藏

            Google PageRank 
Checker - Page Rank Calculator
            少妇高潮惨叫久久久久久 | 久久亚洲sm情趣捆绑调教| 久久97久久97精品免视看| 三级片免费观看久久| 一本色道久久99一综合| 久久免费的精品国产V∧| 青青青国产精品国产精品久久久久| 久久99精品国产麻豆蜜芽| 超级碰碰碰碰97久久久久| 999久久久无码国产精品| 久久久久亚洲AV无码专区桃色 | 亚洲午夜久久久| 99久久99久久| 99精品久久久久久久婷婷| 久久最新精品国产| 久久亚洲AV无码精品色午夜 | 久久香蕉综合色一综合色88| 91麻豆国产精品91久久久| 99久久无码一区人妻| 久久久一本精品99久久精品66| 亚洲人成网站999久久久综合| 亚洲国产精品久久久久婷婷软件| 性欧美大战久久久久久久久| 久久国产免费| 国产精品日韩深夜福利久久| www.久久热| 久久人人爽人人爽人人AV | 久久久久国色AV免费观看| 久久夜色精品国产亚洲| 精品国产一区二区三区久久久狼| 午夜精品久久久久久久无码| 色诱久久av| 久久亚洲精品成人无码网站 | 久久777国产线看观看精品| 亚洲综合熟女久久久30p| 久久精品极品盛宴观看| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久99精品国产麻豆宅宅| 国内精品久久久久影院老司 | 无码人妻久久一区二区三区免费 | 91久久福利国产成人精品|