小k的k-最大子阵:更简单的分治
k-Maximum Subarrays for Small k: Divide-and-Conquer made simpler
摘要:
给定一个n个实数的数组A,最大子数组问题是找到一个具有最大和的连续子数组。k-最大子数组问题是找到k个具有最大和的子数组。对于1-最大值子阵列,在大多数教科书中提出的众所周知的分治算法,虽然是次优的,但很容易实现,并且可以通过简单的改变来加速组合阶段。另一方面,由于组合阶段的复杂性,对于k > 1的唯一已知的分治算法(其对于k的小值是有效的)难以实现。在本文中,我们给出了一个分而治之的解决方案的k-最大子阵列问题,大大简化了合并阶段,同时保持整体运行时间。在算法的合并阶段的设计过程中,我们给出了一个简单的、次线性的、O($k^{1/2} log^3 k$)时间的算法,用于求X + Y的k个最大和,其中X和Y是大小为n的有序数组,$k <= n^2$ .最大的k个和是隐式表示的,并且可以用额外的O(k)时间枚举。据我们所知,这是第一个次线性时间算法,这个问题研究得很好。与以前的解决方案不同,这些解决方案相当复杂,有时难以实现,我们依赖于简单的操作,如合并排序数组,二进制搜索,并选择数组中的$k^{th}$最小数。我们已经实现了我们的算法,并在测试数据上报告了出色的性能。
英文摘要:
Given an array A of n real numbers, the maximum subarray problem is to find a contiguous subarray which has the largest sum. The k-maximum subarrays problem is to find k such subarrays with the largest sums. For the 1-maximum subarray the well known divide-and-conquer algorithm, presented in most textbooks, although suboptimal, is easy to implement and can be made optimal with a simple change that speeds up the combine phase. On the other hand, the only known divide-and-conquer algorithm for k > 1, that is efficient for small values of k, is difficult to implement, due to the intricacies of the combine phase. In this paper we give a divide- and-conquer solution for the k-maximum subarray problem that simplifies the combine phase considerably while preserving the overall running time. In the process of designing the combine phase of the algorithm we provide a simple, sublinear, O($k^{1/2} log^3 k$) time algorithm, for finding the k largest sums of X + Y, where X and Y are sorted arrays of size n and $k <= n^2$. The k largest sums are implicitly represented, and can be enumerated with an additional O(k) time. To our knowledge, this is the first sublinear time algorithm for this well studied problem. Unlike previous solutions, that are fairly complicated and sometimes difficult to implement, ours rely on simple operations such as merging sorted arrays, binary search, and selecting the $k^{th}$ smallest number in an array. We have implemented our algorithms and report excellent performance on test data.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。