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

            堅信:勤能補拙

            2011好題 - 尋找倆已排好序數組的中位數

            問題:
            有兩個已排好序的數組A和B,長度均為n,找出這兩個數組的中間元素。要求時間代價為O(logn)

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

            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 閱讀(450) 評論(0)  編輯 收藏 引用 所屬分類: R_找工復習2011

            導航

            <2010年7月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久这里有精品| 久久精品国产一区二区| 久久综合狠狠综合久久综合88| 伊人久久大香线蕉综合影院首页| 久久久久AV综合网成人| 99久久国产综合精品成人影院| 婷婷久久精品国产| 亚洲狠狠婷婷综合久久久久| 日韩欧美亚洲综合久久影院d3| 无码任你躁久久久久久| 2021久久精品国产99国产精品| 久久精品国产精品亚洲下载| 人妻无码αv中文字幕久久琪琪布| 国产精品女同一区二区久久| 亚洲国产精品无码久久一区二区| 久久er国产精品免费观看8| 久久香综合精品久久伊人| 久久久久人妻精品一区三寸蜜桃 | 久久乐国产综合亚洲精品| 狠狠色丁香久久婷婷综合五月| 久久亚洲av无码精品浪潮| 久久久久亚洲AV片无码下载蜜桃 | 久久精品国产亚洲网站| 亚洲国产精品无码久久久不卡| 日批日出水久久亚洲精品tv| 精品久久久久久久中文字幕| 嫩草影院久久国产精品| 韩国免费A级毛片久久| 一本一本久久aa综合精品| 国产69精品久久久久观看软件| 久久久WWW免费人成精品| 国产精品女同一区二区久久| 国产高清美女一级a毛片久久w| 好久久免费视频高清| 久久国产精品99精品国产987| 亚洲成色www久久网站夜月| 久久亚洲中文字幕精品一区| 久久综合亚洲色一区二区三区| 思思久久好好热精品国产| 久久天天躁狠狠躁夜夜躁2014| 一本一本久久a久久综合精品蜜桃 一本一道久久综合狠狠老 |