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

            JonsenElizee

            Software Developing Blog

            "An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look."
            "Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity."

            ------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard

               :: 首頁 :: 新隨筆 ::  ::  :: 管理 ::
            ISSUE: 輸入上百萬個行星的位置, 求距離第K近的兩個行星。


            Precondition:
                
            1. star field simulation graph is planar.
                
            2. the coordinate of star is (x, y) that is treated as a point。
                
            3. N = 1000000

            1. bucket-sort all points according to x-coordinate. get B buckets.
               
            this is will completed in O(NlogN).
               
               
            struct bucket {
                
            int num;       // number of points in this bucket.
                point* points; // points in this bucket.
                double x;      // value of x-coordinate.
               }
               
               bck[B]; 
            // B buckets got.

            2
               
            struct distance {
                point p1;
                point p2;
                
            double d;     // distance between p1 and p2.
               }

               distance kdis[K]; 
            // to record K small distance. and it's a eliminating-tree.
               kdis[0 to K-1= 0;

               
            for(i = [0, B-2]) // O(B)
               {
                
            // check bck[i] and bck[i+1]
                if(bck[i+1].x - bck[i].x >= kdis[K-1].d && kdis[K-1!= 0)
                {
                    
            // there is no need to check these two buckets.
                    i++;
                    
            continue// save time.
                }

                point
            * poi = bck[i].points;
                
            for(j = [0, bck.num-1]) // O(N/B)
                {
                    point p 
            = poi[j];
                    
            /*
                    find K points in bck[i+1] near to p
                    with binary searching method 
                    according to p.y.
                    
            */
                    kp[K]; 
            // K points got in bck[i+1]

                    
            for(m = [0, K-1]) // O(K)
                    {
                        distance tmp 
            = get_distance(kp[m], p);
                        
            if(tmp.d < kdis[K-1].d)
                        {
                            kdis[K
            -1= tmp;
                            
            // adjust kdis[K-1], for it's a eliminating tree.
                        }
                    }
                }
               }

               
            // finally, the kdis[K-1] is the kth distance in this star graph.
               
            // the whole processing will be completed in O(NlogN) + O(B*N/B*K).
               
            // and SC is O(N) + O(K) = O(N).

            HOW TO FIND K POINTS
            ?
                
            /*
                find K points in bck[i+1] near to p
                with binary searching method 
                according to p.y.
                
            */
            it
            's not complecated! and could be found in O(log(N/B)).


            posted on 2010-10-27 15:18 JonsenElizee 閱讀(1562) 評論(0)  編輯 收藏 引用 所屬分類: Data Structures & Algorithms
            By JonsenElizee
            色婷婷久久久SWAG精品| 国产欧美久久久精品| 亚洲精品美女久久久久99小说 | 久久亚洲精精品中文字幕| 777米奇久久最新地址| 久久996热精品xxxx| 久久国产乱子伦免费精品| 国产精品久久久久乳精品爆| 久久国产免费直播| 久久国产成人午夜AV影院| 久久精品a亚洲国产v高清不卡| 久久精品亚洲欧美日韩久久| 无码国产69精品久久久久网站| 久久99精品免费一区二区| 99久久精品午夜一区二区 | 97久久精品无码一区二区 | 久久免费视频1| 久久se精品一区二区影院| 国产高潮国产高潮久久久| 久久久亚洲裙底偷窥综合| 91精品国产综合久久四虎久久无码一级 | 国产成人久久激情91| 久久人人爽人人爽人人片AV东京热| 色综合久久中文色婷婷| 久久精品国产亚洲AV麻豆网站| 欧美日韩精品久久久免费观看| 久久精品国产亚洲沈樵| 国产精品禁18久久久夂久| 久久男人Av资源网站无码软件| 久久人人爽人人爽人人片av麻烦| 国产精品久久婷婷六月丁香| 国产精品一区二区久久精品涩爱| 亚洲精品tv久久久久久久久久| 久久精品国产只有精品66 | 伊人久久精品无码av一区| 一97日本道伊人久久综合影院| 久久综合色区| 99久久精品国产一区二区| 人妻少妇久久中文字幕一区二区| 午夜精品久久久久久毛片| 精品久久久久久久无码|