
EWCG 2006, Delphi, March 27–29, 2006 In-Place Randomized Slope Selection Henrik Blunck∗ Jan Vahrenhold† Abstract In addition to theoretical considerations, one reason for investigating space-efficient algorithms is that they Slope selection, i.e. selecting the slope with rank k have the potential of using the different stages of hier- n among all 2 lines induced by a collection of points, archical memory, e.g., caches, to a much higher degree P results in a widely used robust estimator for line- of efficiency. Another motivation, especially for de- fitting. In this paper, we demonstrate that it is possi- signing algorithms for statistical data analysis, comes ble to perform slope selection in expected (n log2 n) from the recently increased interest in sensor networks O · time using only constant extra space in addition to the where small-scale computing devices are used to col- space needed for representing the input. lect large amounts of data. Since the memory of such sensor devices usually is very limited, and since trans- 1 Introduction mitting data is much more costly than local computa- tion, it is desirable to process as much data as possible Computing a line estimator, i.e., fitting a line to a locally before transmitting (intermediate) results. collection of n data points p1,...,pn in the plane is a frequentP task in statistical{ analysis.} A frequently Our Results In this paper we show how to solve used robust line estimator is the so-called Theil-Sen the slope selection problem in expected optimal estimator (see [13] and the references therein) which (n log2 n) time while at the same time using only n O considers all 2 lines induced by the points in and constant extra space. Our algorithm follows the ap- selects the line with median slope. This problemP is proach of Matouˇsek [12], and, in the course of im- also known as the (median) slope selection problem plementing his algorithm in-place, we also devise an and has been shown to exhibit an Ω(n log2 n) lower in-place variant of the so-called randomized interpola- bound [6]. Several deterministic algorithms· for solv- tion search technique. This variant, together with an ing this problem in optimal (n log2 n) running time algorithmic subroutine for efficiently constructing and have been presented [5, 6, 10],O however,· as noted by storing a set of randomly sampled intersections, is of Matouˇsek et al. [13], they are based on relatively com- independent interest, since it can be used as a substi- plicated concepts such as parametric search, sorting tute for Megiddo’s parametric search technique [14]. network, expander graphs, or cuttings. More practical approaches have resulted in randomized algorithms 2 Randomized Interpolation Search with expected (n log2 n) running time [7, 12, 15]. O · In the following, the slope selection problem is studied The Model The goal of investigating space-efficient in the dual setting where each point (x, y) is identified with the line (ξ,υ) υ = x ξ y and vice versa. algorithms is to design algorithms that use very little { | · − } extra space in addition to the space used for represent- Selecting the k-th smallest slope is dual to the follow- ing the input. The input is assumed to be stored in ing problem: Given a set of n lines in the plane, find an array A of size n, thereby allowing random access. the k-th leftmost intersection point induced by the We assume that a constant size memory can hold a arrangement of the lines. Since the duality transform constant number of words. Each word can hold one can be performed in an implicit way, we will assume that our input is given as a set of lines in the plane. pointer, or an (log2 n) bit integer, and a constant P 2 number of wordsO can hold one element of the input Since it is infeasible to compute all Θ(n ) intersec- tions induced by , the algorithm of Matouˇsek [12] array. An in-place algorithms uses (1) extra words 2 O maintains a verticalP strip b,e := [b,e] IR IR that of memory. Recently, a number of in-place algorithms h i × ⊂ have been designed for solving geometric problems— is guaranteed to contain the k-th smallest intersection see, e.g., [1, 2, 3, 4, 16]. point. For a parameter r (to be defined later), the al- gorithm first constructs a sample of size r drawn R ∗Westf¨alische Wilhelms-Universit¨at M¨unster, Institut f¨ur from the intersections inside b,e . It then selects two Informatik, Einsteinstr. 62, 48149 M¨unster, Germany. E-mail: intersections from whose xh-coordinatesi are used to [email protected] construct a (narrower)R candidate strip b0,e0 . The al- †Westf¨alische Wilhelms-Universit¨at M¨unster, Institut f¨ur gorithm then checks whether b0,e0 indeedh i contains Informatik, Einsteinstr. 62, 48149 M¨unster, Germany. E-mail: h i [email protected] the k-th smallest intersection point. If this is not the 177 22nd European Workshop on Computational Geometry, 2006 case, the process is repeated for b,e but using a new exactly the number of inversions between the permu- h i sample , otherwise the algorithm iterates with the tation of that arranges the lines in sorted <b-order refined stripR b0,e0 . The iteration terminates when (the verticalP order at x = b) and the permutation h i the number (b,e) of intersections within b,e is no that arranges the lines in sorted <e-order (the ver- larger than r|I: in this| case, the k-th leftmosth intersec-i tical order at x = b). Thus, to efficiently compute tion point can be computed directly by enumerating (b,e) , we can run the classic divide-and-conquer al- all intersections in b,e and selecting the appropriate gorithm|I | for inversion counting—see, e.g., [11]. While one. This refinementh strategyi is referred to as ran- doing so, we keep track of the total number of inver- domized interpolation search—see [12]. The efficiency sions/intersections seen so far and “record” an inter- of the resulting algorithm for slope selection is based section if its rank matches one of the r given ranks. upon the following lemma which (applied iteratively) If the ranks are sorted, we can process them in con- implies that the number (b,e) of intersections that stant extra time per inversion counting operation. We lie inside b,e can be reduced|I | to (r) using an ex- process the “recursion tree” of (our adaption of) the pected constanth i number of iterations:O inversion counting algorithm (see Algorithm 1) in a bottom-up, level-by-level traversal, i.e., without the Lemma 1 (Lemma 2.1 in [13]) Given a set of need of maintaining a recursion stack. Since we need numbers Θ = θ1,θ2,...,θN , an index k (1 k to maintain the r ranks and the intersections com- { } ≤ ≤ N), and an integer r > 0, we can compute in (r) puted so far in an in-place setting, the algorithm is O time an interval [θlo,θhi], such that, with probability divided into three phases: During the first phase, we 1 1/Ω(√r), the k-th smallest element of Θ lies within process the lines stored in A[0,...,n/2 1] and use − this interval, and the number of elements in Θ that A[n/2,...,n 1] to encode the ranks and− the inter- lie within the interval is at most N/Ω(√r). sections found− so far. We then reverse the roles of 2 both subarrays, and finalize the algorithm with a third The above lemma will be applied for N (n ). phase that processes the intersections induced by lines Furthermore, Matouˇsek et al. [13] proved that∈ we O may stored in different halves of the array. choose r := nβ for any 0 <β< 1 without affecting the asymptoticd e efficiency of the resulting algorithm, and thus we will set r := √n . As we will see below, Three In-Place Data Structures For maintaining d e more than (1) numbers or indices, we resort to a our in-place algorithm will be working with binary O encoded numbers, and thus accessing a single num- standard technique in the design of space-efficient al- gorithms, namely to encode a single bit by a permuta- ber θi will take (log2 n) time. Thus, the in-place version of the algorithmO implied by Lemma 1 runs in tion of two objects q and r: For lines q, r with q<b r, the permutation qr encodes a binary zero, and the (r log2 n) time. O It· remains to describe how to construct (and store!) permutation rq encodes a binary one. We use the the sampled set of r = √n intersections in an in- subarray of size n/2 that does not contain the lines to place setting, i.e.,R usingd onlye constant extra space. be processed in the current phase to represent three (implicit) data structures R, L, and I that oc- Furthermore, we need to discuss how to compute D D D cupy a subarray of size 4 r log2 n each: (b,e) . To this effect, we describe an algorithm for · · the|I first| task, which also provides a solution for the Lines to be processed R L I second one. Anticipating the results presented in the D D D next section, we combine them with the above lemma 1 − 0 2 n n 1 and the original analyses of Matouˇsek et al.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages4 Page
-
File Size-