• <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>

            A Za, A Za, Fighting...

            堅(jiān)信:勤能補(bǔ)拙

            2011好題 - 尋找倆已排好序數(shù)組的中位數(shù)

            問(wèn)題:
            有兩個(gè)已排好序的數(shù)組A和B,長(zhǎng)度均為n,找出這兩個(gè)數(shù)組的中間元素。要求時(shí)間代價(jià)為O(logn)

            思路:
            a. 比較自然的思路是歸并算法,不過(guò)時(shí)間復(fù)雜度是O(n),無(wú)法滿足題目要求

            b.
            http://www.binghe.org/2011/05/find-median/ )

            Say the two arrays are sorted and increasing, namely A and B.
            It is easy to find the median of each array in O(1) time.
            Assume the median of array A is m and the median of array B is n.
            Then,
            1′ If m=n, then clearly the median after merging is also m, the algorithm holds.
            2′ If m<n, then reserve the half of sequence A in which all numbers are greater than
            m, also reserve the half of sequence B in which all numbers are smaller than n.
            Run the algorithm on the two new arrays.
            3′ If m>n, then reserve the half of sequence A in which all numbers are smaller than
            m, also reserve the half of sequence B in which all numbers are larger than n.

            Run the algorithm on the two new arrays.

            Time complexity: O(logn)






            posted on 2011-10-16 18:38 simplyzhao 閱讀(454) 評(píng)論(0)  編輯 收藏 引用 所屬分類: R_找工復(fù)習(xí)2011

            導(dǎo)航

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            統(tǒng)計(jì)

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久99这里只有精品国产| 丁香色欲久久久久久综合网| 久久久亚洲欧洲日产国码aⅴ | 亚洲午夜无码AV毛片久久| 无码任你躁久久久久久久| 国产99久久久国产精品小说| 99久久精品日本一区二区免费| 久久精品国产精品国产精品污| 亚洲国产成人精品91久久久| 久久久久久国产精品无码超碰| 亚洲国产成人久久综合碰碰动漫3d| 久久强奷乱码老熟女网站| 久久人妻少妇嫩草AV无码专区| 国产69精品久久久久99| 精品国产乱码久久久久久呢| 国产毛片久久久久久国产毛片| 欧洲成人午夜精品无码区久久| 97精品依人久久久大香线蕉97| 久久免费视频观看| 久久天天躁狠狠躁夜夜2020一| 91久久九九无码成人网站| 久久精品无码专区免费青青| 亚洲а∨天堂久久精品| 色综合色天天久久婷婷基地| 久久人爽人人爽人人片AV| 久久精品免费全国观看国产| 99久久无码一区人妻| 久久精品国产一区| 国产精品天天影视久久综合网| 无码人妻精品一区二区三区久久| 手机看片久久高清国产日韩| 国产午夜精品久久久久九九电影| 国内精品久久久久影院免费| 日产精品久久久一区二区| 少妇熟女久久综合网色欲| 中文字幕亚洲综合久久菠萝蜜| 久久久久九国产精品| 久久精品国产亚洲5555| 欧美日韩精品久久久免费观看| 久久午夜福利电影| 亚洲精品美女久久久久99小说 |