在原来基础上增加了算法E

一、引言

​ 这就是类似求Top(K)问题,什么意思呢?怎么在无序数组中找到第几(K)大元素?我们这里不考虑海量数据,能装入内存。

二、普通算法

算法A:

将数组中的元素升序排序,找到数组下标k-1的元素即可。这是大家最容易想到的方法,如果使用简单排序算法,时间复杂度为O(n^2)。

算法B:

  1. 第一步:初始化长度为K的一个数组,先读入K个元素,将元素降序排序(升序也可以),这时候第K大元素就在最后一个。
  2. 第二步:读入下一个元素就与已排序的第K大元素比较,如果大于,则将当前的第K大元素删掉,并将此元素放到前K-1个正确的位置上(这里就是简单的插入排序了。不了解插入排序的朋友可以看这里图解选择排序与插入排序)。
  3. 时间复杂度:第一步采用普通排序算法时间复杂度是O(k^2);第二步:(N-k)*(k-1) = Nk-k^2+k。所以算法B的时间复杂度为O(NK)当k=N/2(向下取整)时,时间复杂度还是O(n^2)。

其实求第K大问题,也可以求反,即求第N-k+1小问题。这是等价的。所以当K=N/2时,是最难的地方,但也很有趣,这时候的K对应的值就是中位数。

三、较好算法

算法C:

  1. 算法思想:将数据读入一个数组,对数组进行buildHeap(我们这里构建大顶堆),之后对堆进行K次deleteMax操作,第K次的结果就是我们需要的值。(因为是大顶堆,所以数据从大到小排了序,堆排序以后会详细说)。

  2. 现在我们来解决上节遗留的问题,为什么buildHeap是线性的?不熟悉堆的可以看一下 图解优先队列(堆)。我们先来看看代码实现。

    public PriorityQueue(T[] items) {
           //当前堆中的元素个数
           currentSize = items.length;
           //可自行实现声明
           array = (T[]) new Comparable[currentSize +1];
           int i = 1;
           for (T item : items){
               array[i++] = item;
           }
           buildHeap();
       }

    private void buildHeap() {
           for (int i = currentSize / 2; i > 0; i--){
               //堆的下滤方法,可参考上面的链接
               percolateDown(i);
           }
       }

图中初始化的是一颗无序树,经过7次percolateDown后,得到一个大顶堆。从图中可以看到,共有9条虚线,每一条对应于2次比较,总共18次比较。为了确定buildHeap的时间界,我们需要统计虚线的条数,这可以通过计算堆中所有节点的高度和得到,它是虚线的最大条数。该和是O(N)。





定理:包含2h+1-1个节点、高为h的理想二叉树(满二叉树)的节点的高度的和是2h+1-1-(h+1)。

  1. 什么叫满二叉树?满二叉树是完全填满的二叉树,最后一层都是填满的,如图中所示。完全二叉树,是除最后一层以外都是填满的,最后一层外也必须从左到右依次填入,就是上一篇中说的堆的结构。满二叉树一定是完全二叉树,完全二叉树不一定是满二叉树。

  2. 证明定理:

    容易看出,满二叉树中,高度为h上,有1个节点;高度h-1上2个节点,高度h-2上有2^2个节点及一般在高度h-i上的2i个节点组成。
    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA8MAAABbCAYAAABXqFeFAAAgAElEQVR4Xu2dC/xX8/3H32FKiA2rNqaWy1Ykq5XNpZaZ22yU0STdllsMwwq5pFp3lbUSGo1WFFmiXIqwMSRWLoUpq5nM3SpC/8fz8/fJ6dv3cs73nPP9/r7f3+vzePT48fud8znnPM/n8zmf973Oxo0bN5qaCIiACIiACIiACIiACIiACIiACNQiAnUkDNeit61HFQEREAEREAEREAEREAEREAERcAQkDGsgiIAIiIAIiIAIiIAIiIAIiIAI1DoCEoZr3SvXA4uACIiACIiACIiACIiACIiACEgY1hgQAREQAREQAREQAREQAREQARGodQQkDNe6V64HFgEREAEREAEREAEREAEREAERkDCsMSACIiACIiACIiACIiACIiACIlDrCEgYTuCVf/bZZzZt2jSbP3++dezY0Tp16mSzZ8+2xx57zD766CPr0KGDde3a1bbddtsErqYuREAEREAEREAEREAEREAEREAE4hKQMByXoJktXbrUVq9ebQ0bNrT+/ftb69atrVevXtasWTN77bXX7JJLLrFLL73UWrZsmcDV1IUIiIAIiIAIiIAIiIAIiIAIiEBcAhKG4xI0s1mzZlmbNm1s1apVNnDgQLv66qutbdu2rueVK1faxRdf7IThVq1aJXA1dSECIiACIiACIiACIiACIiACIhCXgIThmAQ3btxo69ats3r16tnUqVPt2WefdQLxDjvs4Hp+/PHHbfTo0TZy5Ehr2rRpzKvpdBEQAREQAREQAREQAREQAREQgSQISBhOgqKZrV271gYPHmy77767nXXWWVanTh1DUL7hhhtsxYoVNmDAAKtfv35CV1M3IiACIiACIiACIiACIiACIiACcQhIGI5DL3DuG2+8Yf369XOxwiTMor333nvOPZqkWp07d7b169c7CzKCspoIiIAIiIAIiIAIiIAIiIAIiED5CEgYToj9okWLXKzwqFGjbO+993a94jLN74YPH+6swo888oh16dJFwnBCzNWNCIiACIiACIiACIiACIiACBRLQMJwseQyzps5c6Y99NBDNnToUGvQoIH763333eeSaw0bNszuv/9+a9GihfunJgIiIAIiIAIiIAIiIAIiIAIiUF4CEoYT4E+d4UmTJjnrb7du3Wzrrbd2vb799ts2YsQIe//99+3kk0927tNykU4AuLoQAREQAREQAREQAREQAREQgZgEJAzHBKjTRUAEREAEREAEREAEREAEREAEKo+AhOHKe2e6YxEQAREQAREQAREQAREQAREQgZgEJAzHBKjTRUAEREAEREAEREAEREAEREAEKo+AhOHKe2e6YxEQAREQAREQAREQAREQAREQgZgEJAzHBKjTRUAEREAEREAEREAEREAEREAEKo+AhOHKe2e6YxEQAREQAREQAREQAREQAREQgZgEJAzHBKjTRUAEREAEREAEREAEREAEREAEKo+AhOHKe2e6YxEQAREQAREQAREQAREQAREQgZgEJAzHBKjTRUAEREAEREAEREAEREAEREAEKo+AhOHKe2e18o5fe+01u+KKK6xPnz522GGH1UoGemgREAEREAEREAEREAERqAkEPvnkE7vxxhvtkUcesTfeeMOuueYaa926dU24tUj3IGE4Ei4dXC4CDz/8sI0cOdKGDBlirVq1Ktdt6LoiIAIiIAIiIAIiIAIiIAJfELj77rvtz3/+s40YMcL22GOPsnD5/PPP7dNPP7Vtt9028vUlDEdGphPKQWDjxo322Wef2TbbbFOOy+uaIiACIiACIiACIiACIiACAQIbNmywsWPH2rvvvmsDBgyw+vXrl5zPO++8Y9OnT7emTZva0UcfHfn6EoYjI9MJIiACIiACIiACIiACIiACIlC7Cbz33nt26aWXOq9NQhnr1KlTMiCzZ8+2Bx980HbaaSd76qmn7Nxzz7Vjjz028vUlDEdGphNEQAREQAREQAREQAREQAREoHYTePnll+2iiy6y/v372w9+8IOywFi5cqVdfPHF1r1799IJw7irvvrqq/bvf//bmcO//vWvOx/xrbfe2rmyAqZZs2b2la98pSxQdNHqIfDSSy/ZTTfdZGvWrLELLrjAWrZsWT0PpycRAREQAREQAREQAREQgQolQE6fCRMmWI8ePezxxx+3N99807baais7//zz7Tvf+U5JnqqkwjDByU8++aT9/ve/t7333ttl9X3//fftr3/9q3388cdOWCGj2Ntvv22//vWvJQyXZAhU70WIAcAF4sQTT7TJkye7ydW3b1/3M2wj1njBggW2ePFiO+ecc6xevXpZT/3Xv/5lv/3tb52CxzcSdrVt2zbspariuPXr19v48ePtoIMOsoMPPrik7i5pAyTr4ahRo+y+++7bdCnGVtQxlfZ91pT+NXfivwnG2ooVK9wmoW7duvE7rLIeUJ7PmDHDmJtdu3Z1CvVs7R//+IfbWHE8bZdddnEJFVG61+ZWzet1Uu+VOMZx48bZ8ccfnzf5psZYduKe30knnWTNmzdP6rWonyohwD5h4sSJdtttt1m3bt3stNNOc7Ifv8N9GotxMQmtouIpmTDMR+iWW26x+fPnO1M4k8L7hSMkz5071wnJfNQQio877rioz6LjRWAzAgsXLnRxAE2aNHHxCB07dnSCcdjGJGVcPvDAAy6onw1Uofb888+78dugQQO32SIYv1oaPO6//34n7J5yyinWpUuXrMIuyqzBgwfbUUcdZT/5yU+qSiDmXX744YeuTNczzzzjFmqtVVuOcM2dZGY9380pU6bYf//7XxfLtN122yXTcRX04tn85z//cWtuGDbsP66++mrbd999bfjw4fbVr361CkjEe4RqX6/j0PFsjjjiCJdUJ0wso8bYlsQpbTl06FA744wzKrJsTpwxpHPzE/joo4/syiuvdHtmDEp+HZ80aZLz6MR1OZcRKkm2JROG0XBjBmcTma2GFEDYQD/77LOuzpQ0SEm+5sruCwUJHgNojpYvX2477LCDHXjggXbCCSe4n7ksvevWrXMapaefftoJpmx+olgCGIucx0TdZ599QkHE3YPj27RpYwMHDnT3Wi0NL45+/frZiy++aD/96U+dpSV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AqyQh6JIxYvIr0khT6vaw/CSwNOK+OI04g6rFlyOB9N6vSUYwtpuvvlmV0WhUrKL1+Rx62Pc69ev72K307AK1+Tn171VNwEJwxHfLxp+rI3U/fMNbT+ZNBVTGRFmyoezAcVNCreemmwpSRlDUd2TRZ3Nu9gVha/iT9LcSe4V4lqIEIxHAPXUw8Q9Jnf1mtmTT0xJmTcyvAczB9fMO67Zd6X1esv343O97LjjjhVVd7qmjjQSbpGES/O1pr4h3VccAhKGi6DnU9KvWrVq09mUmUJwyJfyv4hL6ZQYBPyG64EHHihYjiHGZaruVJKXoE0/6qijrGPHjtq8V90bLvxAmjuFGYU5wpc2IXsrSbMUTvMlNc+GnAS4jotNmBG15TFar3Nzgw3C2xFHHBG6dFBxb6G6z2LPS74DSn1SWlJNBKqNgIThIt8oWrJBgwZtVh+wa9euruB2TY0HLPJRK/o0NvVY8RcvXuxq4lEoXi03AVyhxo8fb9QQpK64rFi1d7Ro7sR/97hqrlixwnr06GF169aN32GV9YBAPGPGDCP5E99PfTujvWCt14V5EfYxbtw4Vzte3nuFeWUe4fmddNJJ1rx58+gd6AwRqAACEoaLfEleqz1lypRNPfAh79evn5FUS00EREAEREAEREAEREAEREAERKDmEpAwHOPd4IJDNsznnntuUy9kWcQtp2nTpjF61qkiIAIiIAIiIAIiIAIiIAIiIAJpEpAwHJMuKc/79+/visT7RpwlGaYVAxUTrk4XAREQAREQAREQAREQAREQgZQISBiOCdYnmhk1atSm+OGGDRva0KFDrVmzZjF71+kiIAIiIAIiIAIiIAIiIAIiIAJpEJAwnABV4ocnTJhgM2fONMosUUajdevWCfSsLkRABERABERABERABERABERABNIgIGE4AapYh++9914bPXq0XXTRRUrhnwBTdSECIiACIiACIiACIiACIiACaRKQMJwA3UWLFtkVV1xhnTt3tu7du6s8RAJM1YUIiIAIiIAIiIAIiIAIiIAIpElAwnBMuhQjHzBggLVr18769OmjpFkxeep0ERABERABERABERABERABESgFAQnDMSj70kqNGjWyCy64QIJwDJY6VQREQAREQAREQAREQAREQARKSUDCcJG03333XRs5cqR99NFHduWVV9ouu+xSZE86TQREQAREQAREQAREQAREQAREoNQEJAwXQXzdunU2ZswYe/75523w4MHWtGnTInrRKSIgAiIgAiIgAiIgAiIgAiIgAuUiIGE4g/ydd95p8+bNs9WrV9uZZ55pxx133GZHUEZpypQpNn/+fLvsssusefPm5Xp3uq4IiIAIiIAIiIAIiIAIiIAIiECRBCQMZ4Bbv369kR368ssvt7Fjx1rLli03HUEJpblz59qkSZNc9ug0awl/+umnVqdOHWWmLnJg6zQREAEREAEREAEREAEREAERyEdAwnAWOnfffbfdddddNmzYMNttt93cEQjCCxYssGuvvdbOOOOM1GoJf/755/bKK6/YzTffbPvss48deeSR1rhxY41iERABERABERABERABERABERCBBAlIGM6AuWHDBmcRxkJ88cUXW7169dwRadcSJhHXjTfeaCtXrrStttrKCcT77ruvDRw4UFmqExzw6koEREAEREAEREAEREAEREAEICBhOGMckCW6X79+duihh1q3bt3cX30t4UMOOcR69epldevWTXX0TJs2zSZPnmynnXaa+6cmAiIgAiIgAiIgAiIgAiIgAiKQLAEJwxk8X3jhBWcRHjJkiLVq1cqefPJJGzRokIvfJWFWu3btkn0DGb0hePfv39/WrFljw4cPt7Zt26Z6PXUuAiIgAiIgAiIgAiIgAiIgArWRgIThjLd+zz332G233eYEUVyVJ06caNtvv72tXbvWTjnlFDv22GNTGScff/yxPfjgg85V+p133nHu2ePHj7e99947leupUxEQAREQAREQAREQAREQARGozQQkDAfePmWTEEARRnGTnjlzpn344Yd2/PHH2/Tp052FOLOUErWGKccUtm233XbWtWtXlxSLZFlvvvmmS8w1a9Yse+uttzZ1s/POO7tkXXvuuWfYrnWcCIiACIiACIiACIiACIiACIhASAIShgOgPvjgA7vkkkts+fLl1qJFC8Nlunfv3tasWbOQOPMfRv8rVqyw9957z/VNsqxPPvlki5MaNWpklFa65pprJAwnQl6diIAIiIAIiIAIiIAIiIAIiMDmBCQMB3i8/PLLduGFF9oBBxxgjz76qCunVI6GVXrZsmU2atQoCcPleAG6pgiIgAiIgAiIgAiIgAiIQNUTkDAceMUPP/ywjRkzxrlG4zJdjoYbdadOnVz88MiRIyUMl+Ml6JoiIAIiIAIiIAIiIAIiIAJVT0DC8BevGCvwDTfcYK+++qqdf/75Vr9+fZsyZYqL6T333HNt8eLFtuOOO9r++++/2aB46aWXbM6cOaEHCsLuiSeeaA0bNsx6DlmrFy5caLfccouE4dBUdaAIiIAIiIAIiIAIiIAIiIAIRCMgYfgLXmSLHjx4sDVp0sT69OnjSimR2Xn9+vXWs2dPl0zrhBNOsAYNGkQjXMTRZLRGEJdluAh4OkUEREAEREAEREAEREAEREAEQhCQMPwFJDJIX3XVVdarVy9XX5j2+uuv27hx41ySKwTkli1bhkAa/xAJw/EZqgcREAEREAEREAEREAEREAERyEdAwnANGR8I3Ndff70tWbLE1qxZ48o7UX5pp512svbt27sax2oiIAIiIAIiIAIiIAIiIAIiIALJEJAwnAxH9SICIiACIiACIiACIiACIiACIlBBBCQMV9DL0q2KgAiIgAiIgAiIgAiIgAiIgAgkQ0DCcDIc1YsIiIAIiIAIiIAIiIAIiIAIiEAFEZAwXEEvS7cqAiIgAiIgAiIgAiIgAiIgAiKQDAEJw8lwVC8iIAIiIAIiIAIiIAIiIAIiIAIVREDCcAW9LN2qCIiACIiACIiACIiACIiACIhAMgQkDCfDUb2IgAiIgAiIgAiIgAiIgAiIgAhUEIH/AzplmoWJiOo/AAAAAElFTkSuQmCC" style="font-size: inherit; color: inherit; line-height: inherit; padding: 0px; margin: 0px auto; max-width: 100%; display: inline-block; vertical-align: middle;">

方程两边乘以2得到:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAuAAAAA8CAYAAAAnvQ90AAAeQ0lEQVR4Xu2dB7QeRfnGhxpFQjASqkEBFQWkQ0BAJRCKGA2dgBQJSElosYCAElSkV0VQOAgSCMWAnAChKO1QIiKgKE0JHQIiFpo08z+/8bz5L1++b3dmd2fv/b77zDmcm8vdMvPszDvPW2ee2bNnz3ZqQkAICAEhIASEgBAQAkJACDSCwDwi4I3grJcIASEgBISAEBACQkAICAGPgAi4JoIQEAJCQAgIASEgBISAEGgQARHwBsHWq4SAEBACQkAICAEhIASEgAi45oAQEAJCQAgIASEgBISAEGgQARHwBsHWq4SAEBACQkAICAEhIASEgAi45oAQEAJCQAgIASEgBISAEGgQARHwBsHWq4SAEBACQkAICAEhIASEgAi45oAQEAJCQAgIASEgBISAEGgQARHwBsHWq4SAEBACQkAICAEhIASEgAi45oAQEAJCQAgIASEgBISAEGgQARHwBsHWq4SAEBACQkAICAEhIASEgAi45oAQEAJCQAgIASEgBISAEMhB4K233nLnnnuuu+2229zzzz/vTjnlFLfWWmuVxkwEvDR0ulEICAEhIASEgBAQAkJgICEwbdo0d/HFF7sTTjjBDR8+vPTQRcBLQ6cbhYAQEAJCQAgIASEgBAYKAm+//bY77bTT3D/+8Q935JFHuoUWWqj00EXAS0OnG4WAEBACQkAICAEhIAQGCgL//Oc/3eGHH+5WX311t/fee7t55pmn9NBFwEtDpxuFgBAQAkJACAgBISAEBgoCf/nLX9w3vvENd9hhh7n111+/0rBFwCvBp5uFgBAQAkJACAgBISAEBgICt9xyi/vJT37i9thjD3fXXXe5F154wc0777zu4IMPdp/85CejIOgzAv7mm2+6v/71r27WrFluyJAhbplllnFLLLGEHwh/e/zxx90nPvEJ/7uaEBACQkAICAEhIASEgBDoKwRmz57tzjrrLHfppZe6XXfd1e22225ugQUW8P+P0BQs4wsuuGBw9xon4JRx+fWvf+3OO+88t8EGG7g11ljDPffcc76sCwT8a1/7mrvooovcUkst5Qc4UBulbi688MI5w//sZz/r447e//73D1RIcsf91FNPea10v/32cx/5yEfaXsvcO+mkk9z1118/5+/bbbedGz9+/IBX9O6//343ffp0t//++3uFWO29CCB4b7rpJnffffe5CRMmuPe9732aY5GThHX3xBNPeMvRoEGDIu/W5SEIkBh2+umnuzFjxvgY1U7tj3/8o7fYvfvuu/6SD33oQ+7EE090K6ywQshrevYaw2+HHXZwK620Us+OUwMrh8Crr77qjjrqKLfIIou4b33rW3P42E9/+lP34osvum9+85sd94Z2b2yUgL/xxhvuRz/6kXvyySfdt7/9bffhD394Tp8gR7/4xS/cL3/5S8d1VesrloO3f90FJmTbXnPNNW7HHXf05LJKwH//Gl19vcFb8oMf/MCTx5CanK+88or77ne/6+69916vsY4ePbq+znTpkyCYEPCbb77Zx7axIav9DwHD5sYbb/RZ7yHYaI7NPXsgexdccIF76aWX3AEHHCBjQs0L7O9//7uXg6NGjXJbbrll0F7xm9/8xn3ve99zK664ojv++OPdBz/4wZp71X2PYz859thj3T777BO0n3TfCNXjsgg8/fTTnngzNz7/+c/7x/znP//xyiukHOPMfPPNF/z4XAL+3//+1/3+97/3Fmk0Zh682mqruS984Qtuww03jDK1I3yx6LKJISSWW265uTqJBnHooYd6rRxhgBW8GxvEGYs+bopHH33ULbzwwt7Sv/XWW/ufoWE1pm3dc8897uijj57zwbsRk6I+o3SdeuqpntwwuUMbFgs2EObjNttsE7TpUECfecZ8Q9HrRUsHpPHBBx/0a2nVVVcNgpN5i4LMz0MOOSRKkw96QYMXMX6SZZA5M2bMmIMDlq0RI0ZECUm8AwhYLB+ExYW0Xp1jL7/8srvyyivd1Vdf7fg3MtrW3tJLL10Izb///W+/XldZZRXv4YzZrAof3ocXsGbuuOMO9+lPf9ottthiUT2xfZb94g9/+IO/d7311nN77bVXR29e6wsgAchP9hoMEaG4sj7wtn7xi1/0FnHc6d3eWnkLMpB1y/678cYbByl+GCLw0sNVOnlUux2ngdr/KjKMmO/jjjvOe9I//vGPewifffZZT8qpiGKkPBTbjgTcCDOufRY0mvEzzzzj3fxsaISPYG4P1Zgfe+wxfz2L4Ctf+UpbomSaBO+GIHVjuIVZ+RGExAfhan3kkUc8sXn44Yfdtttu6z9UyNjQxMGMupPZDx76cbvlOrMwMkYs/aEEnPsohs98REEZOnRo0JBRKidOnOg+9rGP+cU0bNiwoPu64SLWDh4mSBKek69//etuq622Cu4692IBJxSMzaobm80nSCLhRSTG4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CQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAIiIBrDggBISAEhIAQEAJCQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAIiIBrDggBISAEhIAQEAJCQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAIiIBrDggBISAEhIAQEAJCQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAIiIBrDggBISAEhIAQEAJCQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAIiIBrDggBISAEhIAQEAJCQAgIgQYREAFvEGy9SggIASEgBISAEBACQkAI/B86evmIVRVO+AAAAABJRU5ErkJggg==" style="font-size: inherit; color: inherit; line-height: inherit; padding: 0px; margin: 0px auto; max-width: 100%; display: inline-block; vertical-align: middle;">
两式相减得到:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAwcAAAA8CAYAAAAzDca8AAAcCklEQVR4Xu2dBbBWxRvG17+BqKiIYoGKYheYOKJgoGIwtjMW4piIid0ttiiCiqLi2IojBggWjkUoNhJiB3Ynyn9+6ywcP77Yk98533125g5674k9z767+z5v7TyzZs2aZdSEgBAQAkJACAgBISAEhIAQaPIIzCNy0ORlQAAIASEgBISAEBACQkAICAGLgMiBBEEICAEhIASEgBAQAkJACAgBkQPJgBAQAkJACAgBISAEhIAQEAJzEJDnQNIgBISAEBACQkAICAEhIASEgDwHkgEhIASEgBAQAkJACAgBISAE5DmQDAgBISAEhIAQEAJCQAgIASFQgoDCiiQSQkAICAEhIASEgBAQAkJACFgERA4kCEJACAgBISAEhIAQEAJCQAiIHEgGhIAQEAJCQAgIASEgBISAEJiDgDwHkgYhIASEgBAQAkJACAgBISAE5DmQDAgBISAEhIAQEAJCQAgIASEgz4FkQAgIASEgBGog8Nlnn5mrrrrKTJo0ySy//PLm0ksvNS1bthRudUDgr7/+MkOGDDHjx483H374oenXr5/ZcMMN69CTxnnln3/+aW6++Wbz3HPPmc8//9zKujBtnPHVl0RHQGFF0bHTnUJACAiBhkfgt99+s6RggQUWMCeeeKL9tx5t5sy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AEhkHMERA5yPkDqnhAQAkJACAgBISAEhIAQyAoBkYOskNZ7hIAQEAJCQAgIASEgBIRAzhEQOcj5AKl7QkAICAEhIASEgBAQAkIgKwREDrJCWu8RAkJACAgBISAEhIAQEAI5R0DkIOcDpO4JASEgBISAEBACQkAICIGsEPg/M+RZavPFL0sAAAAASUVORK5CYII=" style="font-size: inherit; color: inherit; line-height: inherit; padding: 0px; margin: 0px auto; max-width: 100%; display: inline-block; vertical-align: middle;">
所以定理得证。因为堆由完全二叉树构成,所以堆的节点数在2h和2h+1之间,所以意味着这个和是O(N)。所以buildHeap是线性的。所以算法C的时间复杂度是:初始化数组为O(N),buildHeap为O(N),K次deleeMax需要O(klogN),所以总的时间复杂度是:O(N+N+klogN)=O(N+klogN)如果K为N/2时,运行时间是O(NlogN)

算法D:

  1. 算法思想:我们采用算法B的思想,只是我们这里构建一个节点数为K的小顶堆,只要下一个数比根节点大,就删除根节点,并将这个数进行下滤操作。所以算法最终的第K大数就是根节点的数。
  2. 时间复杂度:对K个数进行buildHeap是O(k),最坏情况下假设剩下的N-k个数都要进入堆中进行下滤操作,总的需要O(k+(N-k)logk)。如果K为N/2,则需要O(NlogN)。

算法E:快速选择

参考快速排序及其优化,使用快速排序的思想,进行一点点改动。

  • 算法思想:
  1. 如果S中元素个数是1,那么k=1并将S中的元素返回。如果正在使用小数组的截止方法且|S|<=CUTOFF,则将S排序并返回第K个最大元素
  2. 选取一个S中的元素v,称之为枢纽元(pivot);
  3. 将S-{v}(S中除了枢纽元中的其余元素)划分为两个不相交的集合S1和S2,S1集合中的所有元素小于等于枢纽元v,S2中的所有元素大于等于枢纽元;
  4. 如果k<=|S1|,那么第k个最大元必然在S1中。这时,我们返回quickSelect(S1,k)。如果k=1+|S1|,那么枢纽元就是第k个最大元,我们直接返回枢纽元。否则,这第k个最大元一定在S2中,它就是S2中的第(k-|S1|-1)个最大元。我们进行一次递归调用并返回quickSelect(S2,k-|S1|-1)。
  • java实现:
public class QuickSelect {
    /**
     * 截止范围
     */
    private static final int CUTOFF = 5;

    public static void main(String[] args) {
        Integer[] a = {8, 1, 4, 9, 6, 3, 5, 2, 7, 0, 12, 11, 15, 14, 13, 20, 18, 19, 17, 16};
        int k = 5;
        quickSelect(a, a.length - k + 1);
        System.out.println("第" + k + "大元素是:" + a[a.length - k]);
    }

    public static <T extends Comparable<? super T>> void quickSelect(T[] a, int k) {
        quickSelect(a, 0, a.length - 1, k);
    }

    private static <T extends Comparable<? super T>> void quickSelect(T[] a, int left, int right, int k) {
        if (left + CUTOFF <= right) {
            //三数中值分割法获取枢纽元
            T pivot = median3(a, left, right);

            //开始分割序列
            int i = left, j = right - 1;
            for (; ; ) {
                while (a[++i].compareTo(pivot) < 0) {
                }
                while (a[--j].compareTo(pivot) > 0) {
                }
                if (i < j) {
                    swapReferences(a, i, j);
                } else {
                    break;
                }
            }
            //将枢纽元与位置i的元素交换位置
            swapReferences(a, i, right - 1);

            if (k <= i) {
                quickSelect(a, left, i - 1, k);
            } else if (k > i + 1) {
                quickSelect(a, i + 1, right, k);
            }
        } else {
            insertionSort(a, left, right);
        }
    }

    private static <T extends Comparable<? super T>> T median3(T[] a, int left, int right) {
        int center = (left + right) / 2;
        if (a[center].compareTo(a[left]) < 0) {

            swapReferences(a, left, center);
        }
        if (a[right].compareTo(a[left]) < 0) {
            swapReferences(a, left, right);
        }
        if (a[right].compareTo(a[center]) < 0) {
            swapReferences(a, center, right);
        }
        // 将枢纽元放置到right-1位置
        swapReferences(a, center, right - 1);
        return a[right - 1];
    }

    public static <T> void swapReferences(T[] a, int index1, int index2) {
        T tmp = a[index1];
        a[index1] = a[index2];
        a[index2] = tmp;
    }

    private static <T extends Comparable<? super T>> void insertionSort(T[] a, int left, int right) {
        for (int p = left + 1; p <= right; p++) {
            T tmp = a[p];
            int j;

            for (j = p; j > left && tmp.compareTo(a[j - 1]) < 0; j--) {
                a[j] = a[j - 1];
            }

            a[j] = tmp;
        }
    }
}

//输出结果
//第5大元素是:16

因为我这里是升序排序,所以求第K大,与求第N-k+1是一样的。

  • 最坏时间复杂度:与快速排序一样,当一个子序列为空时,最坏为O(N2)。
  • 平均时间复杂度:可以看出,快速选择每次只用递归一个子序列。平均时间复杂度为O(N)。

四、总结

本篇详述了 求top(K)问题的几种解法,前两种十分平凡普通,后两种比较优一点,暂时给出求解中位数需要O(NlogN)时间。后面介绍使用快速选择方法,每次只用递归一个子序列,可以达到平均O(N)时间复杂度。

面试题:求第K大元素(topK)?的更多相关文章

  1. 算法导论学习之线性时间求第k小元素+堆思想求前k大元素

    对于曾经,假设要我求第k小元素.或者是求前k大元素,我可能会将元素先排序,然后就直接求出来了,可是如今有了更好的思路. 一.线性时间内求第k小元素 这个算法又是一个基于分治思想的算法. 其详细的分治思 ...

  2. 堆实战(动态数据流求top k大元素,动态数据流求中位数)

    动态数据集合中求top k大元素 第1大,第2大 ...第k大 k是这群体里最小的 所以要建立个小顶堆 只需要维护一个大小为k的小顶堆 即可 当来的元素(newCome)> 堆顶元素(small ...

  3. ACM_求第k大元素(两次二分)

    求第k大 Time Limit: 6000/3000ms (Java/Others) Problem Description: 给定两个数组A和B,大小为N,M,每次从两个数组各取一个数相乘放入数组C ...

  4. 行列有序矩阵求第k大元素

    问题来源:http://www.careercup.com/question?id=6335704 问题描述: Given a N*N Matrix. All rows are sorted, and ...

  5. POJ 2985 Treap平衡树(求第k大的元素)

    这题也能够用树状数组做,并且树状数组姿势更加优美.代码更加少,只是这个Treap树就是求第K大元素的专家--所以速度比較快. 这个也是从那本红书上拿的模板--自己找了资料百度了好久,才理解这个Trea ...

  6. 寻找两个已序数组中的第k大元素

    寻找两个已序数组中的第k大元素 1.问题描述 给定两个数组与,其大小分别为.,假定它们都是已按照增序排序的数组,我们用尽可能快的方法去求两个数组合并后第大的元素,其中,.例如,对于数组,.我们记第大的 ...

  7. 《数据结构与算法分析:C语言描述》读书笔记------练习1.1 求第K大的数

    求一组N个数中的第k个最大者,设k=N/2. import java.util.Random; public class K_Max { /** * @param args */ //求第K大的数,保 ...

  8. 如何寻找无序数组中的第K大元素?

    如何寻找无序数组中的第K大元素? 有这样一个算法题:有一个无序数组,要求找出数组中的第K大元素.比如给定的无序数组如下所示: 如果k=6,也就是要寻找第6大的元素,很显然,数组中第一大元素是24,第二 ...

  9. HDU 5249 离线树状数组求第k大+离散化

    KPI Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. Mybatis 系列2

    上篇文章 写了一个Demo简单体现了一下Mybatis的流程.本次,将简单介绍一下Mybatis的配置文件: 上次例子中,我们以 SqlSessionFactoryBuilder 去创建 SqlSes ...

  2. 关于Django升级的一些联想

    刚刚阅读完django1.11的release note,从django1.4一直用到django1.11,以及即将到来的大版本django2.0,Django的版本升级策略和国内的技术现状对比称得上 ...

  3. Maven的使用

    在项目中,我们通常会为项目添加多种多样的依赖包(jar包),去网上下载,然后引入到项目中,很是麻烦. 但是用maven后,这一切都将变得简单起来.由于我的MyEclipse已经集成了maven插件,这 ...

  4. remove duplicate of the sorted array

    description: Given a sorted array, remove the duplicates in place such that each element appear only ...

  5. 常用的几个在线生成网址二维码的API接口

     原创,转载请注明出处! 用接口的好处就是简单,方便,时时更新,二维码生成以后不用保存在本项目服务器上面,可以减少不必要的开支,无需下载安装什么软件,可简单方便地引用,这才是最便捷的免费网址二维码生成 ...

  6. linux内核堆栈

    一:进程的堆栈 内核在创建进程的时候,在创建task_struct的同时会为进程创建相应的堆栈.每个进程会有两个栈,一个用户栈,存在于用户空间,一个内核栈,存 在于内核空间.当进程在用户空间运行时,c ...

  7. MySQL中横表和竖表相互转换

    一  竖表转横表 1. 首先创建竖表 create table student ( id varchar(32) primary key, name varchar (50) not null, su ...

  8. PAT1116: Come on! Let's C

    1116. Come on! Let's C (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue &quo ...

  9. Mysql中外键的 Cascade ,NO ACTION ,Restrict ,SET NULL

    外键约束对子表的含义: 如果在父表中找不到候选键,则不允许在子表上进行insert/update 外键约束对父表的含义: 在父表上进行update/delete以更新或删除在子表中有一条或多条对应匹配 ...

  10. capwap学习笔记——初识capwap(五)(转)

    3. CAPWAP Binding for IEEE 802.11 ¢ CAPWAP协议本身并不包括任何指定的无线技术.它依靠绑定协议来扩展对特定无线技术的支持. ¢ RFC5416就是用来扩展CAP ...