On the number of heaps and the cost of heap construction

Size: px
Start display at page:

Download "On the number of heaps and the cost of heap construction"

Transcription

1 On the number of heaps and the cost of heap construction Hsien-Kuei Hwang Institute of Statistical Science Academia Sinica Taipei 5 Taiwan Jean-Marc Steyaert LIX École Polytechnique 928 Palaiseau France November 2, 200 Abstract Heaps constitute a well-known data structure allowing the implementation of an efficient O(n log n sorting algorithm as well as the design of fast priority queues. Although heaps have been known for long, their combinatorial properties are still partially worked out: exact summation formulae have been stated, but most of the asymptotic behaviors are still unknown. In this paper, we present a number of general (not restricting to special subsequences asymptotic results that give insight on the difficulties encountered in the asymptotic study of the number of heaps of a given size and of the cost of heap construction. In particular we exhibit the influence of arithmetic functions in the apparently chaotic behavior of these quantities. It is also shown that the distribution function of the cost of heap construction using Floyd s algorithm and other variants is asymptotically normal. Introduction Heap is an elementary data structure often used in applications concerned with priority queues and partial (as well as total ordering. It first appeared in Williams Heapsort algorithm [30], which happened to be the first in-place O(n log n sorting algorithm. Besides its original applications to sorting, heap has wide applications in algorithm design, see Aho et al. []. It serves as the prototype, both conceptually and in actual implementations, of many complex data structures in computational geometry (see Preparata and Shamos [25] and in graph-theoretical problems (see Noltemeier [2], Mehlhorn and Tsakalidis [20]. A (max heap is an array with elements a j, j n, satisfying the path-monotonic property: a j a j/2 for j = 2, 3,..., n, where x denotes the integral part of x. It can be viewed as a binary tree in which the value of each element is not smaller than that of its children. The construction of a heap from an arbitrary set of n keys can be performed efficiently in linear time using Floyd s algorithm (see [7, 5.2.3], but it is easy to see that the exact number of operations used varies according to the nature of the permutation on the input keys. Likewise, the number of heaps of a given size n is not a steadily growing function of n, but proves to have a chaotic rate of growth. Several authors have proposed partial answers to these problems. Knuth states the basic Most results of this paper appeared as Rapport de Recherche, LIX/RR/93/07, Ecole polytechnique, 993; only quite recently did we revise the paper. This work was partially supported by the ESPRIT Basic Research Action No. 74 (ALCOM II and by the AQSI research action of the French Ministry for Research and Space.

2 recurrence relation for the number of heaps, and gives an explicit solution as a product; he also shows that the expected cost used by Floyd s algorithm to construct a heap is linear; Doberkat [5] derives the probability generating functions for the number of exchanges and comparisons used by Floyd s algorithm, he also finds the asymptotics of the first two moments; Sprugnoli [27] examines in more detail the average case behavior of Floyd s heap-construction algorithm [7] for general values of the heap size. The method of Doberkat is via probability generating functions and that of Sprugnoli relies largely on refining the results on special sequences. We propose a new approach to the asymptotic study of the number of heaps and the cost of heap construction. It is based on explicit decomposition of the solution to the basic recurrence characteristic of heap structures. The decomposition is in terms of some digital sums (sums expressible using the binary digits of n in base 2. From this canonical representation, elementary asymptotic methods then give the asymptotic behavior of the quantity in question. This paper is organized as follows. We state the basic recurrence together with some notations in the next section. The general solution, in terms of digital sums, of this recurrence is presented in Section 3. Then we apply this result to determine an asymptotic expression for the number of heaps and the cost (mean and variance of Floyd s heap-construction algorithm. Our results on the mean and the variance improve upon that of Doberkat [5] and that of Sprugnoli [27]. In the final section, we establish the asymptotic normality of the cost used by Floyd s algorithm under the uniform permutation model. 2 The basic divide-and-conquer recurrence A characteristic property of a heap, when viewing as a binary tree, is that at least one of the two subtrees of the root node is complete (i.e., it contains 2 k elements for some positive integer k, and then the size of the other subtree is at least half and at most twice this number. Furthermore, this property recursively applies to each node. Given a heap H of size N with left and right subtrees L and R of respective sizes L and R, an additive cost function ϕ on heaps is defined by a relation ϕ[h] = τ[h] + ϕ[l] + ϕ[r], ( for some cost function τ. Summing over all heaps of size N, which obviously decompose into subheaps of the same sizes L and R, we thus define a function f that satisfies the same recurrence on sizes, t being the sum function for τ. Since at least one of L or R is complete, the relation ( can be written into a more precise form as follows. For positive integer k and a given sequence {t n } n f 2 k +j = t 2 k +j + f 0 = 0, f = t, { f2 k + f 2 k +j, if 0 j < 2 k, f 2 k + f j, if 2 k j < 2 k, which is referred to as the (additive heap recurrence (see [27], [3, Ch. 3]. Observe that we can incorporate the two cases into one by writing f n = f 2 log 2 2n/3 + f n 2 log 2 2n/3 + t n (n 2, (2 where 2 log 2 2n/3 represents the unique power of two lying between n/2 and 2n/3. Also the associated generating functions satisfy f(z = t n z n + ( f z 2 k z 3 2k z 3 2k + (z 2k + z 2k f j z j, n k k 2 k j<2 k 2

3 where f(z = n f nz n. Here and in the following, H n denotes the total number of ways to rearrange the integers {, 2,..., n} into a heap. It is obvious that H n satisfies the multiplicative heap recurrence: ( 2 k + j 2 H 2 k +j = k H 2 k H 2 k +j, if 0 j < 2 k, ( 2 k + j 2 k H 2 k H j, if 2 k j < 2 k, since the root has to contain the largest key and the remaining elements can be assigned independently to the left and right subheaps. The sequence {H n } n 2 =, 2, 3, 8, 20, 80, 20, 896, 3360, 9200, 79200, , , , , , , increases very fast and is the A05697 entry in Sloane s On-Line Encyclopedia of Integer Sequences ( njas/sequences. It is more convenient to work with h n = log(n!/h n since h n satisfies (2 with t n = log n. Knuth [7, p. 54] expresses the number of heaps of size n via the product of the sizes of all its subtrees. Denoting by s i, i =, 2,..., n, these sizes, the number H n writes: H n = n! i n s. i The s i s are generally of the form 2 k, for some positive integer k, except for the nodes lying on the special path whose ranks (in hierarchical order are of the form 2 j (+{n/2 j }, where {x} denotes the fractional part of x. If we consider the (backward difference of f n : ϕ n = f n = f n f n, then we obtain, { ϕ2 ϕ 2 k +j = τ 2 k +j + k +j, 0 j < 2 k, ϕ j, 2 k j < 2 k, (k, with the initial condition ϕ 0 = 0, where τ n = t n. Equivalently, if we write n = (b L... b 0 2 in base 2, then this recurrence can be re-written as ϕ n = ϕ (bl...b 0 2 = τ (bl...b ϕ (bl 2...b 0 2 = τ (bj...b j L Before solving (2, we note that there is another very similar type of recurrences [0] { φ2 k + φ φ 2 k +j = τ 2 k +j + 2 k +j, if 0 j 2 k ; φ 2 k + φ j, if 2 k j 2 k, (3 which occurs as the solution of the following equation φ n = τ n + min (φ j + φ n j (n 2, j n/2 (with φ given when the sequence {τ n } n 0 is strictly concave, namely, τ n+2 2τ n+ + τ n < 0 for all n 0. 3

4 On the other hand, when the sequence {τ n } n 0 is strictly convex, the solution φ n satisfies [0] φ n = φ n/2 + φ n/2 + τ n (n 2. (4 This type of recurrences occurs very often in the analysis of algorithms and was systematically treated by an analytic approach by Flajolet and Golin [6]; see also [5]. Recurrences of the types (2 and (4 are typical representatives of the divide-and-conquer recurrences that one naturally encounters from its designing principle: A n = A x(n + A y(n + B n (n n 0 >, with some initial conditions, where B n is some given sequence (called toll function, A n is certain cost measure related to the algorithm in question, x(n and y(n usually satisfy 0 < x(n, y(n < n, their values depending upon the dividing strategy. Besides (2 and (4, let us mention another recurrence recently studied by Panny and Prodinger [22] for the analysis of bottom-up mergesort algorithm: A n = A x(n + A n x(n + B n (n 2, (5 with x(n = 2 log 2 n, where y denotes the least integer y. A typical phenomenon of the behaviors of divide-and-conquer recurrences is that they often involve certain periodic fluctuations depending on the instance size. Intuitively, this is due to the fact that in each dividing step, the sizes of the two subproblems are not necessarily identical. Consequently, the cumulative (recursive effect renders the global behavior less smooth, or even chaotic. Such a fluctuating behavior relies sensitively upon the dividing strategy. Roughly, the more balanced the two sequences x(n and y(n are, the more smooth the resulting oscillating behavior is. For example, the recurrence (4 should be expected to involve oscillating functions that are more smooth than those of (2 and (5. A detailed comparison realizing these arguments for the two recurrences (5 and 4 can be found in [22] and in [4]. Notations. n is a positive integer, and n = (b L b L...b 0 2, the binary representation of n, where L = log 2 n and b L =. n j = (b j...b 0 2 for j =, 2,..., L; n 0 =. v 2 (n denotes the exponent of 2 in the prime decomposition of n; ν(n denotes the number of -digits in the binary representation of n. All limits are taken to be n. 3 Explicit formula To solve the heap recurrence (2 explicitly, we observe that when n = 2 k+, the recurrence is essentially linear: f 2 k+ = t 2 k+ + 2f 2 k, which can be solved easily by iteration. From this, we can find the solution for the sequences {2 k }, {2 k + 2 k },.... But this process does not lead readily to a general solution; see Sprugnoli [27]. Hence, we begin with another approach. We first extend a classical counting argument for Young tableaux of a given shape (see [7, 5..4, 5.2.3] and give an explicit solution to the general recurrence (2. 4

5 Lemma. For n, the solution f n of the heap recurrence (2 is given by f n = ( n n 2 j 2 j t 2 j + t nj, (6 j L for any given sequence {t n } n. 0 j L Proof. As in [7], we call the nodes lying on the path from to n special nodes. Let Σ and Σ 2 denote the first sum and the second sum, respectively. Then Σ counts the weights of nonspecial nodes under the cost function t n, and Σ 2 counts similarly the weights of special nodes. Nonspecial nodes are always perfectly balanced, so their sizes are of the form 2 j. Now any node of rank β = (c r...c 0 2 lying in the range n/2 j < β < n/2 j has as subtree size s β = 0 i<j 2i = 2 j, since s β is the number of positive integers n whose binary representation is of the form (c r...c 0 2, where is any 0- string. Hence, the number of nonspecial subtrees of size 2 j is n n 2 j 2 j. On the other hand, the number of positive integers n whose binary representation has the form (b L...b j for = 0,,..., j is 0 i<j 2i + (b j... b = (b j... b 0 2. Hence, the special subtree sizes are n, n L,..., n 0 = n j. This completes the proof. Note that Σ can be re-written in the form Σ = n 2 j (t 2 j+ t 2 j j L and, by using n j = 2 j ( + {n/2 j }, 0 j L Σ 2 = 0 j L j L+ Similarly, the solution of the recurrence (3 is given by (φ 0 = 0 φ n = ( n n 2 j 2 j τ 2 j + τ nj. t 2 j + t n, (7 t 2 j (+{n/2 j }. (8 0 j L As an easy illustrative example, take t n = an + b with a > 0, we obtain readily 2 f n = anl + (a + bn a2 L+ + a(l + 2 = an log 2 n + F (log 2 nn + O(log n, where F is a continuous periodic function of period : F (u = a + b a{u} a2 {u} = a 2 + b a log 2 + a log 2 k Z\{0} e 2kπiu χ k (χ k + (χ k = 2kπi/ log 2, u R, By the basic property of heap: if a node β has rank (c r...c 0 2, then its left and right children have respective ranks (c r...c 00 2 and (c r...c We could imagine the mergesort variant on heaps, namely: in order to sort a heap, sort the left and right subheaps (divide and then merge (conquer the two sorted heaps by using, for instance, a linear merge; then the number of comparisons f n used in the worst case is described by (2 with t n = n 2 for n 2 and t = 0. So that if we do not take into account the additional space needed, then this algorithm takes f n + C n = nl 2 L+ n/2 + L {n/2} + C n comparisons to sort n elements, where C n is the number of comparisons used to construct a heap from a permutation. As far as the number of comparisons is concerned, this would be the fastest heapsort in the worst case, although it destroys the basic characteristic of heaps. 5

6 the series being absolutely convergent. This simple example reflects the general pattern of solutions to (2. An interesting consequence of Lemma is the following necessary and sufficient condition for the asymptotic linearity of f n. Lemma 2. Assume that f n satisfies the heap recurrence (2. Then f n is asymptotically linear: f n cn iff t n = o(n, and t 2 j 2 j <. (9 The constant c is given by c = j t 2 j 2 j. j L j This result says that without loss of generality, we can, under the hypotheses of Lemma 2, consider only the special sequence {f 2 k } k, as far as the dominant asymptotics is concerned. Proof. Assume that (9 holds. By (6 and t n = o(n, we have f n = ( n 2 j n 2 j t 2 j + ({ n } { n } 2 j 2 j t 2 j + t nj j L j L 0 j L = n t 2 j 2 j + o 2 j + o ( { n } 2 j + 2 j = n j L j L j L t 2 j 2 j + o(n. (0 Since the sum j L t 2 j 2 j converges (by assumption, we obtain f n cn. Note that the expression (0 holds as long as t n = o(n. On the other hand, assume that f n = c 0 n + o(n for some constant c 0. Then by definition (2 t n = f n f 2 log 2 2n/3 f n 2 log 2 2n/3 = c 0 n c 0 2 log 2 2n/3 c 0 (n 2 log 2n/3 2 + o(n = o(n. This implies, by (0 and f n c 0 n, that c 0 = c = t 2 j 2 j <. j This proves the necessity part and the lemma. As to recurrence (3, the constant c in (9 is modified to be c = j 0 τ 2 j2 j, under the same conditions. Note that c may be zero since we did not impose that t n 0. 4 The number of heaps In this section, we derive an asymptotic expression for the number of heaps H n of size n. To this end, we apply Lemma to the sequence h n = log(n!/h n. The extremal and average order of the arithmetic functions involved are also discussed. 6

7 4. The asymptotic behavior of H n First of all, since h n satisfies (2 with t n = log n, Lemma 2 gives, h n n log(2 j 2 j = n 2 log j log( 2 j = n. j j Let α = 2 log 2+ j 2 j log( 2 j. In order to obtain an asymptotically equivalent approximation for H n, we need to determine h n up to the constant term. To this aim, we examine each sum in (6 in more detail. Again, by formula (8, the contribution to h n by the sum Σ with t n = log n is given by Σ 2 = j log 2 + ω(n, 0 j L where ω(n := log( + {n/2 j } 0 j L oscillates between O(log n and O(. Consider now Σ in (7 with t n = log n. Simple algebraic manipulations lead to Σ = j L n 2 j log 2j+ 2 j = α n ν(n log 2 0 j L+ where q = j log( 2 j is a constant and is bounded for all n. Thus r(n = j j L+ log(2 j j log 2 q r(n 2 L + O ( n 2, { n 2 j } log 2 j 2 j (n, h n = Σ + Σ 2 = α n ν(n log 2 + ω(n (L + log 2 q r(n 2 L + O ( n 2. ( Returning to H n, we have H n = n! e hn = n! 2 L++ν(n e α n+q+r(n ω(n ( + 2 L + O ( n 2. For convenience, set Q = e q = j ( 2 j = and R(n = e r(n = j ( 2 j 2 j {n/2 j }. Since ν(n = j 0 {n/2j } = 0 j L {n/2j } + n/2 L, we conclude, by Stirling s formula, our main asymptotic result for H n. 7

8 Theorem. The number of heaps of size n satisfies the asymptotic expression H n = 2Q ( 2πΠ(log 2 nr(n n n+ 3 2 e (α+n + 2 L+ + 2n + O ( n 2, where α = 2 log 2 + j 2 j log( 2 j and Π(log 2 n = 2 ν(n {log 2 n} e ω(n = 2 2{log 2 n} {log 2 n} Note that this is not an usual asymptotic formula since log n log H n n n+3/2 e (α+n 0 j L 2 {n/2j } + {n/2 j }. (2 varies between 0 and log 4 (0/9 (see (3 below. In particular, if n = 2 L+, then H n = 4 ( 2πe α n n+ 3 2 e αn n + 3 4n + O ( n 2 ; If n = 2 L, then H n = 4Q ( 2π n n+ 3 2 e αn n + 7 2n + O ( n 2 ; But when n = 3 (4m+ (namely, n = ( for m 0, we obtain L = 2m and where b = log(0/9/2 and κ = H n = 20Q π κn n+ 3 2 b/ log 2 e αn n ( + O ( n ( 9 log4 3 ( 4 j 3 ( 4 j 0 j ( 4 j ( j ( 2 4 j. 3 (+ 2 4 j Remark. By the definition of h n and (, the information-theoretic lower bound for the number of comparisons to construct a heap of size n is given by h n log 2 = log 2 n! H n = α ω(n n ν(n L + log 2 log 2 + O(, The constant α/ log 2 is approximately equal to ; see [9]. 4.2 Extremal order We now derive bounds for functions R(n and Π(u. Taking logarithms and making use of the inequalities 0 {n/2 j } 2 j, we have, for all n, R(n exp 2 j log( 2 j = j 8

9 Figure : The function Π plotted against log 2 n for n from 32 to 024; the upper and lower bounds as predicted by (3 are also shown. Direct expansion of the function log ( ( 2 j /( 2 j leads to log R(n = l 2 l l(2 l+ 0 j L so that the oscillating behavior of log R(n is completely determined by the reversed weighted digital sums 0 j L b j2 lj. Proposition. For all n, the inequalities hold, where b = log(0/9/2 and c is some constant. b j 2 lj, 0 < c n b/ log 2 Π(log 2 n 2 (3 Proof. Observe first that by (2 and the elementary inequalities we obtain the upper and the lower bounds e log 2 2 2x x 2 (0 x, e 2x log x (0 x, Π(log 2 n e(log 2 ( e 2 log 2 L e(log 2n +/ log 2+log log 2/ log 2. Such a lower bound obtained by considering only the maximum of each term (as a continuous function is, however, too crude and unattainable. 9

10 To prove the better lower bound in (3, we consider the function ϖ(n := ψ ( {n/2 j }, where ψ(x := log( + x x log 2, j L so that Π(log 2 n = 2 2{log 2 n} {log n} 2 e ϖ(n. Note that the function ψ(x attains the maximum value at ( log 2/ log satisfies the recurrence ( n 2 ϖ(n = ϖ(n 2 L L + ψ. log 2 (n 2 L <j L 2 j Also ϖ(n then so that We prove that lim sup n ϖ(n L = b = 2 (ψ(/3 + ψ(2/3 = 2 log 0 9. (4 The proof consists of mainly two parts: First, we prove that if n = ( = 4L/2+ 3 L 2 b ϖ(n L 2 b + b, lim sup n ϖ(n L Second, if n is not of the form (5, then n can be written as (L even, (5 b. (6 n = (00 0 } 0 {{ 0} 2, (7 λ where λ 0, λ and is a binary sequence. We prove by induction that ϖ(n (L + b (n, (8 which together with (6 proves (4. Consider first the case when n is of the form (5. Then ϖ(n = { ( ψ 3 ( j + ψ 3 2 } 3 4 j. j L/2 By using the elementary inequalities (by concavity ( b ψ(/3 x/2 + ψ(2/3 x 2b + log 2 x 2 40 (0 x /4, (9 0

11 we obtain L 2 b ϖ(n L ( 2 b + log < L 2 b + ( log j L/2 4 j < L 2 b + b, for even L. This proves (6. We now consider the case when n is of the form (7. Since ψ(0 = ψ( = 0, the initial cases n 4 are easily checked. We assume that n 5. Then ϖ(n can be decomposed as (writing y = (0. 2 ( ϖ(n = ψ 2 + y j L 2s 4 + j s+ when λ = 0, for some s 0; and ϖ(n = ( ψ 2 j + y 2 j j<λ j s { ψ 0 j L 2s λ ψ({2 j y}, { ( ψ j + y ( j + ψ j + y } 4 j ( ( 3 2λ λ 4 j + y 2 2 λ+ 4 j + ψ 3 2λ λ 4 j + y } 2 λ 4 j ψ({2 j y}, when λ 2, for some s 0. Consider first the case λ = 0. By induction, max ψ({2 j y} (L 2s 3b. 0 y 0 j L 2s 4 It remains to show that for s 0 ( max 0 y ψ 2 + y + { ( ψ j + y ( j + ψ j + y } 4 j j s+ (2s + 3b, which follows from the elementary inequalities { ( max ψ 0 y j + y 2 4 j and + ψ ( j + y } 4 j 2b (j 2, max {ψ(/2 + y/2 + ψ(3/4 + y/4 + ψ(3/8 + y/8} 3b. 0 y

12 Next consider the case λ = 2. Again by induction max ψ({2 j y} (L 2s λb, and we need to show that where for brevity A s (y := ψ 0 y 0 j L 2s λ max A s(y (2s + 3b, 0 y ( 2 + y + { ( ψ j + y ( j + ψ j + y } 4 j. j s+ The case s = 0 is easily checked numerically; indeed, we have max A s(y 3b y Assume that s. Then by applying the inequality (9 max A s(y max A { ( 0(y + max ψ 0 y 0 y 0 y j + y 2 4 j 2 j s+ ( b sb + log 2 max y (2s + 3b < (2s + 3b. 2 j s+ ( 2 + ψ j + y } 4 j 5/3 y 4 j The remaining case λ > 2 is treated as follows. Observe first that we have, by the monotonicity of ψ, ( max ψ 0 y 2 j + y 2 j (λ 3ψ(/4 (λ 3b. 3 j<λ Then for λ 3 { ( max ψ 0 y 2 + y ( + ψ y 4 { ( max ψ 0 y 2 + y + ψ 2 4b 0.04; and, by (9, max 0 y j s { ( ψ ( + ψ ( 4 + y 4 3 2λ λ 4 j + y 3 2λ λ + y + ψ 2 λ+ 4 j ( λ+ 3 2sb + log λ 2sb , 2 2 λ+ ( y 6 ( 2 + ψ + ψ 3 2λ λ + y } 2 ( λ y } 8 ( 2 + ψ 3 2λ λ 4 j + y } 2 λ 4 j

13 for λ 3. This proves (8 for λ 3 and the proposition. Remarks. The proof does not reveal why repeating the pattern 0 yields the best possible upper bound for ϖ(n/l. Roughly, this is because the average of ψ(/3 and ψ(2/3 is somehow the most balanced choice. Here is another rough explanation (by calculations. Write first x = {n/2 L }. Then ϖ(n = 0 j<l ψ({2j x}. The function b ψ(x is positive for 0 x 0.27 and 0.62 x <. So if we assume that (8 holds, then, by induction, we are left with the interval [0.27, 0.62] for x. Then 2b ψ(x ψ({2x} > 0 for /3 < x 0.62, and we are left with the smaller interval [0.27, /3]. Continuing this way, we see that /3 is a limiting point in some sense, which means that n is of the form (5. An alternative proof of (4 is sketched as follows. Let x = x [0, and x j = {2 j x}. We show that for all x [0, and m (ψ(x j b K := 3ψ(/2. j m It suffices to show that there is an interval I [0, such that (i for all x I there is an m 0 such that x m0 + I, (ψ(x j b 0, and (ψ(x j b K/3, j m 0 j m for all m < m 0 ; and (ii for all x I ψ(x b K/3, and x 2, x 3 I. For ϖ(n, we take I = [0, /4] [/3, and check the above conditions case by case. 4.3 Average order Although the function ϖ(n oscillates between O( and O(log n, its sum function has a much smoother behavior. We determine its average order, namely n m n ω(m. Note that we have the Fourier series log( + {x} {x} log 2 = 3 2 log 2 + k 0 e 2kπix 2kπi convergent for all x, where Ei(, z is the integral exponential defined by Ei(, z = e zw w dw (Ei(, 4kπi Ei(, 2kπi, ( arg(z < π, the integration being taken along any path in the z-plan with a cut along the negative real axis. Now summing all such series for j =, 2,..., L, we obtain ( 3 ϖ(n = 2 log 2 L + Ei(, 4kπi Ei(, 2kπi e 2kπni/2j, 2kπi k 0 j L which is nothing but a mere translation of ϖ(n into trigonometric sums. Yet the formula still says something about the average order of ϖ(n: ( 3 ϖ(m = n 2 log 2 log 2 n + O(, m n which can be obtained by the following Ergodic-type result. 3

14 Lemma 3. Let ϕ(x be any real, continuous function on [0, ] and differentiable in (0,. Define φ(m = 0 j log 2 m ϕ({m/2j }. Then n m n ( φ(m = 0 ϕ(x dx log 2 n + O(. In other words, the lemma says that the average order of the function φ(m is equal to log 2 n times the mean value of the function ϕ in [0, ]. Proof. (Sketch Let Φ(n := m n φ(m. Then Φ(n = n+ φ(x dx n+ (φ(x φ( x dx + O(. The first integral on the right-hand side is easily seen to be n+ ( φ(x dx = ϕ(x dx n log 2 n + O(n. The second integral is O(n by the differentiability of ϕ(x. If we take ϕ(x = x, we obtain, in view of the relation ν(n = 0 j L {n/2j } + n/2 L, n m n 0 ν(m = 2 log 2 n + O(; and in general n m n ν q (m = q + log 2 n + O( (q > 0, where ν q (n := 0 j L {n/2j } q. The implied constant in the O-term depends on q. Other examples are given in the next section. 5 The cost of constructing heaps In this section, we again apply the solution (6 of the heap recurrence to refine previous analyses on the mean and the variance of the cost used by Floyd s algorithm to construct a heap from a random sequence. Moreover, the asymptotic normality of the cost is also established. Our methods apply equally to other variants of Floyd s algorithm. Let us first recall the algorithm. It is divide-and-conquer in nature. Briefly, to construct a heap of size n, construct the left and the right subheaps, respectively, by the same procedure and then find the proper place in one of the two subheaps for the root element (by comparisons and keyexchanges. We assume, throughout this section, that a uniform probability measure is assumed on the set of permutations of size n, n. Knuth [7, p. 55] showed that, given a random permutation of size n, Floyd s algorithm preserves randomness in each recursive step. This means that given a random permutation of n elements, the output obtained by Floyd s algorithm is a random heap of size n, namely, all heaps of size n are equally likely. 4

15 Thus, with the notations of (, the probability generating function P n (z for some cost measure of the algorithm like the number of exchanges running over all heaps of size n satisfies (see (2 P 0 (z = P n (z = P 2 log 2 2n/3 (zp n 2 log 2 2n/3 (zq n(z (n, (20 where Q n (z is the probability generating function for the cost of placing the root element of a heap of size n into one of its two subheaps. Note that Q n (z is always a polynomial for all finite n. From (6, we have the explicit representation P n (z = Q n (z j L Q 2 j (z n/2j n/2 j Q nj (z (n. Our analysis below applies to all versions of heap-construction algorithm using divide-and-conquer paradigm such that the randomness is preserved in each conquering step, the randomness is preserved. For concreteness, we consider in detail the number of exchanges used by Floyd s algorithm. Note that if ξ n is a random variable distributed according to P n (z, namely, E(z ξn = P n (z, then E(ξ n satisfies (2 with t n = Q n(, and Var(ξ n satisfies (2 with t n = Q n(+q n( Q n( 2. Cumulants of higher order obey the same type of recurrences. We derive in 5.3 an effective version (namely, with convergence rate of a theorem of Haigh [] on the asymptotic normality of sums of independent random variables. Then we apply this theorem to probability generating functions of the form (20. Roughly, our theorem states that if the maximum degree M n of the polynomial Q n (z is small compared to the standard deviation σ n of the random variable ξ n (more precisely, M n /σ n 0, then the random variable ξ n is asymptotically normal in the sense of convergence in distribution. This fact is well-known since Laplace from the early development of Probability Theory. From now on, given a random permutation π n of size n, let ξ n denote the number of exchanges used to construct a heap from π n using Floyd s algorithm [7, 5.2.3]. 5. The mean of ξ n From [7, 5.2.3], the mean number of exchanges E(ξ n satisfies the heap recurrence (2 with t n = n j n log 2 j = L + (L + 2/n 2 L+ /n, the average height of a node in a random heap of size n (see [7, p. 55]. Applying formulae (7 and (8, we get the following result that is more general than that of Sprugnoli [27]; see also [3, Ch. 3]. Theorem 2. The expected number of exchanges E(ξ n used by Floyd s heap construction algorithm satisfies ( log n E(ξ n = µn + ϖ (n + ϖ 2 (n + O (n, (2 n where µ = 2 + j j(2j = , ϖ (n is defined by ϖ (n = j L + {n/2 j } 2 + {n/2 j }, 5

16 and ϖ 2 (n = O( is given by ϖ 2 (n = n 2 L j 2 j + j j ( + {n/2 j } + { n } j2 j 2 j + 2 j (2 j (2 j+. j j j Furthermore, ϖ (n satisfies lim inf n ϖ (n L =, and lim sup n ϖ (n L = By Lemma 4, the average order of the arithmetic function ϖ (n is (3/2 2 log 2 log 2 n + O(. Proof. (Sketch With the exact formulae (7 and (8, simple manipulations using Maple lead to (2. The inequalities for ϖ (n are derived by similar arguments as in Proposition (both approaches apply. In particular, if n = 2 L+, then ( log n E(ξ n = µn L + µ + O ; n if n = 2 L, then ( log n E(ξ n = µn L + µ + O. n But if n = 3 (4m+, we have E(ξ n = µn 7 20 L + O(, In general, for n = (2 (m+d /(2 d, d 2, we have E(ξ n = µn + K d L + O(, where K d = d(2 d 0 j<d (2 d j 2 d + 2 j. 5.2 The variance of ξ n We now consider the variance of ξ n. Since the variance of a sum of independent random variables is equal to the sum of the variance of individual random variable, the variance of ξ n satisfies (2 with t n = n j n = 6 2L n 4L+ n 2 log 2 j 2 n j n log 2 j 2 L2 n + 2L+2 L n 2 4 L n 6 n + 2L+3 n 2 L2 n 2 4 L n 2 4 n 2, by partial summation. With the help of Maple, we obtain the following result, improving that of Doberkat [5]. 6

17 Figure 2: The function (E(ξ n µn/l plotted against {log 2 n} for n from 2 to 024; the upper bound as predicted by Theorem 2 is also shown. Theorem 3. The variance of the number of exchanges satisfies the asymptotic expression ( log Var (ξ n = σ 2 2 n n + ϖ 3 (n + ϖ 4 (n + O (n, n where σ 2 = 2 j j2 (2 j 2 = , ϖ 3 (n is defined by and satisfies ϖ 3 (n = 2 0 j L {n/2 j } {n/2 j } 2 ( + {n/2 j } 2, and ϖ 4 (n = O(: lim inf n ϖ 3 (n L = 0, and lim sup n ϖ 3 (n L = , j 2 2 j ϖ 4 (n = (2 j 2 + j j { n 2 j } 2 j (j 2 + 4j j+ (2j j (j 2 2j (2 j 2 (2 j+ 2. The average order of ϖ 3 (n is (6 log 2 4 log 2 n + O(. Note that, unlike the two functions ϖ(n/l and ϖ (n/l whose maximum values are achieved when n = (00 0 2, the maximum of ϖ 3 /L is (asymptotically attained when n is of the form n = ( , 7

18 so that the ratio / is equal to 5 (ψ 3(5/3 + ψ 3 (0/3 + ψ 3 (20/3 + ψ 3 (9/3 + ψ 3 (8/3, where ψ 3 (x = 2(x x 2 /( + x 2. The main difference is that the underlying function ψ 3 (x attains its maximum value /4 at x = /3 and not between /3 and /2. The proof follows the same arguments used in the proof of Proposition ; we omit the proof here since it is very involved and uninteresting. 5.3 Asymptotic normality From the special form (20 satisfied by the probability generating function P n (z of ξ n, we show that ξ n is asymptotically normal in the sense of convergence in distribution. Theorem 4. The distribution functions of the random variables (ξ n µn/(σ n converge to the standard normal distribution: ( sup P ξn µn <x< σ n < x x ( e t2 /2 dt log n 2π = O, (22 n where the two constants µ and σ 2 are defined in Theorems 2 and 3, respectively. These results are special cases of the following lemma refined from that of Haigh [], where we explicitly characterize the convergence rate to the normal law by a direct approach based upon characteristic functions and the Berry-Esseen smoothing inequality (see [23]. Lemma 4. Let {X n } n be a sequence of random variables taking only non-negative integral values with mean µ n and variance σn. 2 Suppose that the probability generating function P n (z of Ω n can be decomposed as P n (z = P nj (z, j k n for some sequence {k n } n, where the P nj (z are polynomials such that (i each P nj (z is itself a probability generating function of some random variable, say, X nj ( j k n ; and (ii M n σ n 0, (23 where M n = max j kn deg P nj (z. Then the distribution of X n is asymptotically Gaussian: ( sup P Xn µ n < x x ( e t2 /2 dt 2π = O Mn. (24 <x< σ n Proof. First of all, we have µ n = j k n µ nj and σn 2 = j k n σnj 2, where µ nj and σnj 2 denote, respectively, the mean and the variance of X nj. Note that condition (23 implies that σ n as n. Let ϕ nj (t = P nj (e it/σn and define the random variable Xn = (X n µ n /σ n with characteristic function ϕ n (t; then ϕ n (t = e µnit/σn P n (e it/σn. Set T n = ησ n /M n, where η > 0 is a sufficiently small constant. By the expansion log ϕ nj (t = µ ( nj it σ2 nj σ n 2σn 2 t 2 E( Xnj µ nj + O σn 3 t 3 ( j k n, t T n, 8 σ n

19 we obtain ( log ϕ n (t = t2 2 + O Mn t 3 σ n ( t T n, since σ 3 n E( X nj µ nj 3 2 max X j kn nj σ n j k n = 2M n σ n. Using e w w e w, for all complex w, we have ( ( ( ϕ n (t e t2 /2 Mn = O t 3 exp t2 σ n 2 + O Mn t 3 σ n ( Mn = O t 3 e t2 /2 ( t T n, σ n by choosing η sufficiently small. Thus we obtain Tn ϕ n (t e t2 /2 t dt = O T n ( Mn σ n t 3 e t2 /2 dt = O By the Berry-Esseen smoothing inequality [23, p. 09], we have ( sup P Xn µ n < x x ( e t2 /2 dt <x< σ n 2π = O Tn + Tn T n ( Mn σ n. ϕ n (t e t2 /2 t dt, and the result (24 follows. This simple lemma can be used to derive the asymptotic normality (with convergence rate for many combinatorial quantities; see [4]. Proof of Theorem 4. By (20 and Lemma 5, we need only check that the degree of the polynomials Q n (z in (20 is small compared to the standard deviation of ξ n, which is O( n. The special form of Q n (z given in [5] has no importance here. Since Q n (z is the probability generating function for inserting the root into one of the two subheaps that are of height O(log n, it is obvious that the degree of Q n (z is O(log n. From this, an application of Lemma 5 yields sup <x< P ( ξ n E(ξ n Var(ξn < x x 2π e t2 /2 dt = O ( Mn In view of Theorems 2 and 3, the above equation is asymptotically equivalent to (22. Our approach also applies to the number of comparisons used by Floyd s algorithm and similar results as Theorems 2 4 hold. Here is a more general rule. The cost (the number of key-exchanges or the number of comparisons used to construct a heap from a random permutation of n elements by algorithms using divide-and-conquer paradigm such that the randomness is preserved in each conquer step is asymptotically normal in the sense of convergence in distribution. 9 σ n.

20 It is merely a rule since a formal statement of a precise version would be too heavy. In particular, this rule applies to the heap construction algorithms in [3, 9, 2, 29], the basic ideas of improvement being more or less due to Floyd. Our approach also gives in most cases more precise quantitative results in the form of (22. In connection with this, it should be pointed out that the original on-line algorithm proposed by Williams [30] to construct a heap is not linear in the worst case and that the randomness is not guaranteed (see [24] in each step. The average case analysis of its behavior is more difficult; see [2, 8, 2]. Likewise, a precise analysis of the expected behavior of heapsort is very involved since successive deletions destroy the initial random character. Recent progress in this direction can be found in [26]. 6 Conclusion Analysis in distribution of algorithms has received much attention recently and several tools have been now well developed; see Mahmoud [8], Szpankowski [28]. Specializing to divide-and-conquer algorithms that preserve randomness in each conquer step, we have seen that the limiting distribution of the cost of heap-related algorithms is normal in most cases. For algorithms leading to the recurrence (4, we have, in general, probability generating functions of the form { pn (z = p n/2 (zp n/2 (zq n (z, if n 2; p 0 (z = p (z =. This is studied in detail in [6] in the case of mergesort where the limiting distribution is still of a Gaussian type. Since divide-and-conquer is widely used in algorithmics, the general methods presented in this paper together with those in [6, 6] might be applied to the analysis in distribution of other algorithms. We have seen that digital sums of the form j L ψ({n/2j } appear naturally in the analysis of heap recurrences. We studied the extremal properties of such sums for three special cases: ψ(x = log( + x x log 2, ψ(x = ( + x 2 /( + x and ψ(x = 2(x x 2 /( + x 2 and the behavior of the last case is very different from those of the first two cases. In general, the extremal problems for arbitrary ψ(x satisfying some regularity conditions are very difficult. Acknowledgements The first author thanks Tsung-Hsi Tsai for helpful suggestions. References [] A. V. Aho, J. E. Hopcroft and J. D. Ullman, The Design and Analysis of Computer Algorithms, Addison-Wesley, MA, 974. [2] B. Bollabás and I. Simon, Repeated random insertion into a priority queue structure, Journal of Algorithms, 6 ( [3] S. Carlsson, Average-case results on heapsort, BIT, 27 (

21 [4] W.-M. Chen, H.-K. Hwang and G.-H. Chen, The cost distribution of queue-mergesort, optimal mergesorts, and power-of-two rules, Journal of Algorithms, 30 (999, [5] E. E. Doberkat, An average case analysis of Floyd s algorithm to construct heaps, Information and Control, 6 ( [6] P. Flajolet and M. Golin, Mellin transforms and asymptotics: the mergesort recurrence, Acta Informatica, 3 ( [7] R. W. Floyd, Algorithm 245, tree 3, Communications of the ACM, 7 ( [8] A. Frieze, On the random construction of heaps, Information Processing Letters, 27 ( [9] G. H. Gonnet and J. I. Munro, Heaps on heaps, SIAM Journal on Computing, 5 ( [0] J. M. Hammersley and G. R. Grimmett, Maximal solutions of the generalised subadditive inequality, in Chapter 4 of Stochastic Geometry, Ed. by E. F. Harding and D. G. Kendall, John Wiley and Sons, 974. [] J. Haigh, A neat way to prove asymptotic normality, Biometrika, 58 ( [2] R. Hayward and C. McDiarmid, Average case analysis of heap building by repeated insertion, Journal of Algorithms, 2 ( [3] H.-K. Hwang, On the solutions of some divide-and-conquer recurrences, Rapport de Recherche, LIX/RR/93/0, Ecole Polytechnique, 993. [4] H.-K. Hwang, On convergence rates in the central limit theorems for combinatorial structures, European Journal of Combinatorics, 9 ( [5] H.-K. Hwang, Asymptotic expansions of the mergesort recurrences, Acta Informatica, 35 (998, [6] H.-K. Hwang, Limit theorems for mergesort, Random Structures Algorithms, 8 (996, [7] D. E. Knuth, The Art of Computer Programming, Volume III Sorting and Searching, Addison- Wesley, Second Edition, 998. [8] H. M. Mahmoud, Sorting. A Distribution Theory, Wiley-Interscience, New York, [9] C. J. H. McDiarmid and B. A. Reed, Building heaps fast, Journal of Algorithms, 0 ( [20] K. Mehlhorn and A. Tsakalidis, Data structures, Chapter 6 of Handbook of Theoretical Computer Science, pp , Edited by J. van Leeeuwen, Elsevier Science Publishers, Amsterdam, 990. [2] H. Noltemeier, Dynamic partial orders and generalised heaps, Computing (Supplement, 7 ( [22] W. Panny and H. Prodinger, Bottom up mergesort, a detailed analysis, Algorithmica, 4 (

22 [23] V. V. Petrov, Sums of Independent Random Variables, Translated from the Russian by A. A. Brown, Springer-Verlag, Berlin-Heidelberg, New-York, 975. [24] T. Porter and I. Simon, Random insertion into a priority queue structure, IEEE Transactions on Software Engineerings, SE- ( [25] F. P. Preparata and M. I. Shamos, Computational Geometry, Springer-Verlag, Berlin, 985. [26] R. Schaffer and R. Sedgewick, The analysis of heapsort, Journal of Algorithms 5 ( [27] R. Sprugnoli, Recurrence relations on heaps, Algorithmica, 5 (996, [28] W. Szpankowski, Average Case Analysis of Algorithms on Sequences, Wiley-Interscience, New York, 200. [29] I. Wegener, BOTTOM-UP-HEAPSORT, a new variant of HEAPSORT beating, on an average, QUICKSORT (if n is not very small, Theoretical Computer Science, 8 ( [30] J. W. J. Williams, Algorithm 232: Heapsort, Communications of the ACM, 7 (

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map

More information

Permutations with Inversions

Permutations with Inversions 1 2 3 47 6 23 11 Journal of Integer Sequences, Vol. 4 2001, Article 01.2.4 Permutations with Inversions Barbara H. Margolius Cleveland State University Cleveland, Ohio 44115 Email address: b.margolius@csuohio.edu

More information

ROSENA R.X. DU AND HELMUT PRODINGER. Dedicated to Philippe Flajolet ( )

ROSENA R.X. DU AND HELMUT PRODINGER. Dedicated to Philippe Flajolet ( ) ON PROTECTED NODES IN DIGITAL SEARCH TREES ROSENA R.X. DU AND HELMUT PRODINGER Dedicated to Philippe Flajolet (98 2) Abstract. Recently, 2-protected nodes were studied in the context of ordered trees and

More information

k-protected VERTICES IN BINARY SEARCH TREES

k-protected VERTICES IN BINARY SEARCH TREES k-protected VERTICES IN BINARY SEARCH TREES MIKLÓS BÓNA Abstract. We show that for every k, the probability that a randomly selected vertex of a random binary search tree on n nodes is at distance k from

More information

Asymptotic and Exact Poissonized Variance in the Analysis of Random Digital Trees (joint with Hsien-Kuei Hwang and Vytas Zacharovas)

Asymptotic and Exact Poissonized Variance in the Analysis of Random Digital Trees (joint with Hsien-Kuei Hwang and Vytas Zacharovas) Asymptotic and Exact Poissonized Variance in the Analysis of Random Digital Trees (joint with Hsien-Kuei Hwang and Vytas Zacharovas) Michael Fuchs Institute of Applied Mathematics National Chiao Tung University

More information

in (n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 n log 4 2 n element moves (cf. [24]) in the worst case. Soon after th

in (n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 n log 4 2 n element moves (cf. [24]) in the worst case. Soon after th The Ultimate Heapsort Jyrki Katajainen Department of Computer Science, University of Copenhagen Universitetsparken 1, DK-2100 Copenhagen East, Denmark Abstract. A variant of Heapsort named Ultimate Heapsort

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

Partial Quicksort. Conrado Martínez

Partial Quicksort. Conrado Martínez Partial Quicksort Conrado Martínez Abstract This short note considers the following common problem: rearrange a given array with n elements, so that the first m places contain the m smallest elements in

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &

More information

Average Case Analysis of the Boyer-Moore Algorithm

Average Case Analysis of the Boyer-Moore Algorithm Average Case Analysis of the Boyer-Moore Algorithm TSUNG-HSI TSAI Institute of Statistical Science Academia Sinica Taipei 115 Taiwan e-mail: chonghi@stat.sinica.edu.tw URL: http://www.stat.sinica.edu.tw/chonghi/stat.htm

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 4: Divide and Conquer (I) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Divide and Conquer ( DQ ) First paradigm or framework DQ(S)

More information

Divide-and-Conquer Algorithms Part Two

Divide-and-Conquer Algorithms Part Two Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller

More information

EXPECTED WORST-CASE PARTIAL MATCH IN RANDOM QUADTRIES

EXPECTED WORST-CASE PARTIAL MATCH IN RANDOM QUADTRIES EXPECTED WORST-CASE PARTIAL MATCH IN RANDOM QUADTRIES Luc Devroye School of Computer Science McGill University Montreal, Canada H3A 2K6 luc@csmcgillca Carlos Zamora-Cura Instituto de Matemáticas Universidad

More information

Ecient and improved implementations of this method were, for instance, given in [], [7], [9] and [0]. These implementations contain more and more ecie

Ecient and improved implementations of this method were, for instance, given in [], [7], [9] and [0]. These implementations contain more and more ecie Triangular Heaps Henk J.M. Goeman Walter A. Kosters Department of Mathematics and Computer Science, Leiden University, P.O. Box 95, 300 RA Leiden, The Netherlands Email: fgoeman,kostersg@wi.leidenuniv.nl

More information

Expected heights in heaps. Jeannette M. de Graaf and Walter A. Kosters

Expected heights in heaps. Jeannette M. de Graaf and Walter A. Kosters Expected heights in heaps Jeannette M. de Graaf and Walter A. Kosters Department of Mathematics and Computer Science Leiden University P.O. Box 951 300 RA Leiden The Netherlands Abstract In this paper

More information

Review Of Topics. Review: Induction

Review Of Topics. Review: Induction Review Of Topics Asymptotic notation Solving recurrences Sorting algorithms Insertion sort Merge sort Heap sort Quick sort Counting sort Radix sort Medians/order statistics Randomized algorithm Worst-case

More information

arxiv:math.pr/ v1 17 May 2004

arxiv:math.pr/ v1 17 May 2004 Probabilistic Analysis for Randomized Game Tree Evaluation Tämur Ali Khan and Ralph Neininger arxiv:math.pr/0405322 v1 17 May 2004 ABSTRACT: We give a probabilistic analysis for the randomized game tree

More information

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count Types of formulas for basic operation count Exact formula e.g., C(n) = n(n-1)/2 Algorithms, Design and Analysis Big-Oh analysis, Brute Force, Divide and conquer intro Formula indicating order of growth

More information

On the Exponent of the All Pairs Shortest Path Problem

On the Exponent of the All Pairs Shortest Path Problem On the Exponent of the All Pairs Shortest Path Problem Noga Alon Department of Mathematics Sackler Faculty of Exact Sciences Tel Aviv University Zvi Galil Department of Computer Science Sackler Faculty

More information

Building Heaps Fast C. J. H. MCDIARMID* Institute of Economics and Statistics, Oxford University, Oxford, England AND B. A. REED

Building Heaps Fast C. J. H. MCDIARMID* Institute of Economics and Statistics, Oxford University, Oxford, England AND B. A. REED JOURNAL OF ALGORITHMS 10, 352-365 (1989) Building Heaps Fast C. J. H. MCDIARMID* Institute of Economics and Statistics, Oxford University, Oxford, England AND B. A. REED Bell Communication Research, 435

More information

Mergesort, File: msfinal6.tex Date: (678) BOTTOM-UP MERGESORT y. A Detailed Analysis

Mergesort, File: msfinal6.tex Date: (678) BOTTOM-UP MERGESORT y. A Detailed Analysis BOTTOM-UP MERGESORT y A Detailed Analysis W. PANNY 1 and H. PRODINGER 1 Department of Computer Science, University of Economics, Augasse {6, A-1090 Vienna, Austria. E-mail: wolfgang.panny@wu-wien.ac.at

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern

Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern D. Merlini and R. Sprugnoli Dipartimento di Sistemi e Informatica viale Morgagni 65, 5034, Firenze, Italia merlini@dsi.unifi.it,

More information

The Subtree Size Profile of Plane-oriented Recursive Trees

The Subtree Size Profile of Plane-oriented Recursive Trees The Subtree Size Profile of Plane-oriented Recursive Trees Michael Fuchs Department of Applied Mathematics National Chiao Tung University Hsinchu, Taiwan ANALCO11, January 22nd, 2011 Michael Fuchs (NCTU)

More information

Asymptotic Counting Theorems for Primitive. Juggling Patterns

Asymptotic Counting Theorems for Primitive. Juggling Patterns Asymptotic Counting Theorems for Primitive Juggling Patterns Erik R. Tou January 11, 2018 1 Introduction Juggling patterns are typically described using siteswap notation, which is based on the regular

More information

The Moments of the Profile in Random Binary Digital Trees

The Moments of the Profile in Random Binary Digital Trees Journal of mathematics and computer science 6(2013)176-190 The Moments of the Profile in Random Binary Digital Trees Ramin Kazemi and Saeid Delavar Department of Statistics, Imam Khomeini International

More information

Data selection. Lower complexity bound for sorting

Data selection. Lower complexity bound for sorting Data selection. Lower complexity bound for sorting Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 12 1 Data selection: Quickselect 2 Lower complexity bound for sorting 3 The

More information

Notes by Zvi Rosen. Thanks to Alyssa Palfreyman for supplements.

Notes by Zvi Rosen. Thanks to Alyssa Palfreyman for supplements. Lecture: Hélène Barcelo Analytic Combinatorics ECCO 202, Bogotá Notes by Zvi Rosen. Thanks to Alyssa Palfreyman for supplements.. Tuesday, June 2, 202 Combinatorics is the study of finite structures that

More information

Approximate Counting via the Poisson-Laplace-Mellin Method (joint with Chung-Kuei Lee and Helmut Prodinger)

Approximate Counting via the Poisson-Laplace-Mellin Method (joint with Chung-Kuei Lee and Helmut Prodinger) Approximate Counting via the Poisson-Laplace-Mellin Method (joint with Chung-Kuei Lee and Helmut Prodinger) Michael Fuchs Department of Applied Mathematics National Chiao Tung University Hsinchu, Taiwan

More information

Weighted Sums of Orthogonal Polynomials Related to Birth-Death Processes with Killing

Weighted Sums of Orthogonal Polynomials Related to Birth-Death Processes with Killing Advances in Dynamical Systems and Applications ISSN 0973-5321, Volume 8, Number 2, pp. 401 412 (2013) http://campus.mst.edu/adsa Weighted Sums of Orthogonal Polynomials Related to Birth-Death Processes

More information

Everything You Always Wanted to Know about Quicksort, but Were Afraid to Ask. Marianne Durand

Everything You Always Wanted to Know about Quicksort, but Were Afraid to Ask. Marianne Durand Algorithms Seminar 200 2002, F. Chyzak (ed., INRIA, (2003, pp. 57 62. Available online at the URL http://algo.inria.fr/seminars/. Everything You Always Wanted to Know about Quicksort, but Were Afraid to

More information

A Note on the Approximation of Perpetuities

A Note on the Approximation of Perpetuities Discrete Mathematics and Theoretical Computer Science (subm.), by the authors, rev A Note on the Approximation of Perpetuities Margarete Knape and Ralph Neininger Department for Mathematics and Computer

More information

data structures and algorithms lecture 2

data structures and algorithms lecture 2 data structures and algorithms 2018 09 06 lecture 2 recall: insertion sort Algorithm insertionsort(a, n): for j := 2 to n do key := A[j] i := j 1 while i 1 and A[i] > key do A[i + 1] := A[i] i := i 1 A[i

More information

A Tight Lower Bound for Top-Down Skew Heaps

A Tight Lower Bound for Top-Down Skew Heaps A Tight Lower Bound for Top-Down Skew Heaps Berry Schoenmakers January, 1997 Abstract Previously, it was shown in a paper by Kaldewaij and Schoenmakers that for topdown skew heaps the amortized number

More information

RON M. ROTH * GADIEL SEROUSSI **

RON M. ROTH * GADIEL SEROUSSI ** ENCODING AND DECODING OF BCH CODES USING LIGHT AND SHORT CODEWORDS RON M. ROTH * AND GADIEL SEROUSSI ** ABSTRACT It is shown that every q-ary primitive BCH code of designed distance δ and sufficiently

More information

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i A Tight Lower Bound for the Worst Case of Bottom-Up-Heapsort 1 by Rudolf Fleischer 2 Keywords : heapsort, bottom-up-heapsort, tight lower bound ABSTRACT Bottom-Up-Heapsort is a variant of Heapsort. Its

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 5: Divide and Conquer (Part 2) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ A Lower Bound on Convex Hull Lecture 4 Task: sort the

More information

Distribution of the Number of Encryptions in Revocation Schemes for Stateless Receivers

Distribution of the Number of Encryptions in Revocation Schemes for Stateless Receivers Discrete Mathematics and Theoretical Computer Science DMTCS vol. subm., by the authors, 1 1 Distribution of the Number of Encryptions in Revocation Schemes for Stateless Receivers Christopher Eagle 1 and

More information

Continued Fraction Digit Averages and Maclaurin s Inequalities

Continued Fraction Digit Averages and Maclaurin s Inequalities Continued Fraction Digit Averages and Maclaurin s Inequalities Steven J. Miller, Williams College sjm1@williams.edu, Steven.Miller.MC.96@aya.yale.edu Joint with Francesco Cellarosi, Doug Hensley and Jake

More information

The space requirement of m-ary search trees: distributional asymptotics for m 27

The space requirement of m-ary search trees: distributional asymptotics for m 27 1 The space requirement of m-ary search trees: distributional asymptotics for m 7 James Allen Fill 1 and Nevin Kapur 1 Applied Mathematics and Statistics, The Johns Hopkins University, 3400 N. Charles

More information

Basic counting techniques. Periklis A. Papakonstantinou Rutgers Business School

Basic counting techniques. Periklis A. Papakonstantinou Rutgers Business School Basic counting techniques Periklis A. Papakonstantinou Rutgers Business School i LECTURE NOTES IN Elementary counting methods Periklis A. Papakonstantinou MSIS, Rutgers Business School ALL RIGHTS RESERVED

More information

LARGE DEVIATIONS OF TYPICAL LINEAR FUNCTIONALS ON A CONVEX BODY WITH UNCONDITIONAL BASIS. S. G. Bobkov and F. L. Nazarov. September 25, 2011

LARGE DEVIATIONS OF TYPICAL LINEAR FUNCTIONALS ON A CONVEX BODY WITH UNCONDITIONAL BASIS. S. G. Bobkov and F. L. Nazarov. September 25, 2011 LARGE DEVIATIONS OF TYPICAL LINEAR FUNCTIONALS ON A CONVEX BODY WITH UNCONDITIONAL BASIS S. G. Bobkov and F. L. Nazarov September 25, 20 Abstract We study large deviations of linear functionals on an isotropic

More information

LAWS OF LARGE NUMBERS AND TAIL INEQUALITIES FOR RANDOM TRIES AND PATRICIA TREES

LAWS OF LARGE NUMBERS AND TAIL INEQUALITIES FOR RANDOM TRIES AND PATRICIA TREES LAWS OF LARGE NUMBERS AND TAIL INEQUALITIES FOR RANDOM TRIES AND PATRICIA TREES Luc Devroye School of Computer Science McGill University Montreal, Canada H3A 2K6 luc@csmcgillca June 25, 2001 Abstract We

More information

Bootstrap random walks

Bootstrap random walks Bootstrap random walks Kais Hamza Monash University Joint work with Andrea Collevecchio & Meng Shi Introduction The two and three dimensional processes Higher Iterations An extension any (prime) number

More information

are the q-versions of n, n! and . The falling factorial is (x) k = x(x 1)(x 2)... (x k + 1).

are the q-versions of n, n! and . The falling factorial is (x) k = x(x 1)(x 2)... (x k + 1). Lecture A jacques@ucsd.edu Notation: N, R, Z, F, C naturals, reals, integers, a field, complex numbers. p(n), S n,, b(n), s n, partition numbers, Stirling of the second ind, Bell numbers, Stirling of the

More information

LIMIT LAWS FOR SUMS OF FUNCTIONS OF SUBTREES OF RANDOM BINARY SEARCH TREES

LIMIT LAWS FOR SUMS OF FUNCTIONS OF SUBTREES OF RANDOM BINARY SEARCH TREES LIMIT LAWS FOR SUMS OF FUNCTIONS OF SUBTREES OF RANDOM BINARY SEARCH TREES Luc Devroye luc@cs.mcgill.ca Abstract. We consider sums of functions of subtrees of a random binary search tree, and obtain general

More information

Partial match queries in random quadtrees

Partial match queries in random quadtrees Partial match queries in random quadtrees Nicolas Broutin nicolas.broutin@inria.fr Projet Algorithms INRIA Rocquencourt 78153 Le Chesnay France Ralph Neininger and Henning Sulzbach {neiningr, sulzbach}@math.uni-frankfurt.de

More information

Isomorphisms between pattern classes

Isomorphisms between pattern classes Journal of Combinatorics olume 0, Number 0, 1 8, 0000 Isomorphisms between pattern classes M. H. Albert, M. D. Atkinson and Anders Claesson Isomorphisms φ : A B between pattern classes are considered.

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

Conway s RATS Sequences in Base 3

Conway s RATS Sequences in Base 3 3 47 6 3 Journal of Integer Sequences, Vol. 5 (0), Article.9. Conway s RATS Sequences in Base 3 Johann Thiel Department of Mathematical Sciences United States Military Academy West Point, NY 0996 USA johann.thiel@usma.edu

More information

Forty years of tree enumeration

Forty years of tree enumeration October 24, 206 Canada John Moon (Alberta) Counting labelled trees Canadian mathematical monographs What is our subject? Asymptotic enumeration or Probabilistic combinatorics? What is our subject? Asymptotic

More information

arxiv: v1 [cs.dm] 15 Jul 2016

arxiv: v1 [cs.dm] 15 Jul 2016 Best-case Analysis of MergeSort with an Application to the Sum of Digits Problem A manuscript (MS) intended for future journal publication arxiv:1607.04604v1 [cs.dm] 15 Jul 016 MAREK A. SUCHENEK California

More information

Lecture 2: Divide and conquer and Dynamic programming

Lecture 2: Divide and conquer and Dynamic programming Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in

More information

arxiv: v1 [math.co] 8 Feb 2014

arxiv: v1 [math.co] 8 Feb 2014 COMBINATORIAL STUDY OF THE DELLAC CONFIGURATIONS AND THE q-extended NORMALIZED MEDIAN GENOCCHI NUMBERS ANGE BIGENI arxiv:1402.1827v1 [math.co] 8 Feb 2014 Abstract. In two recent papers (Mathematical Research

More information

Mapping the Discrete Logarithm: Talk 2

Mapping the Discrete Logarithm: Talk 2 Mapping the Discrete Logarithm: Talk 2 Joshua Holden Joint work with Daniel Cloutier, Nathan Lindle (Senior Theses), Max Brugger, Christina Frederick, Andrew Hoffman, and Marcus Mace (RHIT REU) Rose-Hulman

More information

Stochastic Realization of Binary Exchangeable Processes

Stochastic Realization of Binary Exchangeable Processes Stochastic Realization of Binary Exchangeable Processes Lorenzo Finesso and Cecilia Prosdocimi Abstract A discrete time stochastic process is called exchangeable if its n-dimensional distributions are,

More information

Counting k-marked Durfee Symbols

Counting k-marked Durfee Symbols Counting k-marked Durfee Symbols Kağan Kurşungöz Department of Mathematics The Pennsylvania State University University Park PA 602 kursun@math.psu.edu Submitted: May 7 200; Accepted: Feb 5 20; Published:

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 Data Structures and Algorithms Chapter 3 1. Divide and conquer 2. Merge sort, repeated substitutions 3. Tiling 4. Recurrences Recurrences Running times of algorithms with recursive calls can be described

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 9 Divide and Conquer Merge sort Counting Inversions Binary Search Exponentiation Solving Recurrences Recursion Tree Method Master Theorem Sofya Raskhodnikova S. Raskhodnikova;

More information

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem CS 577 Introduction to Algorithms: Jin-Yi Cai University of Wisconsin Madison In the last class, we described InsertionSort and showed that its worst-case running time is Θ(n 2 ). Check Figure 2.2 for

More information

FACTORS OF GIBBS MEASURES FOR FULL SHIFTS

FACTORS OF GIBBS MEASURES FOR FULL SHIFTS FACTORS OF GIBBS MEASURES FOR FULL SHIFTS M. POLLICOTT AND T. KEMPTON Abstract. We study the images of Gibbs measures under one block factor maps on full shifts, and the changes in the variations of the

More information

On the Density of Languages Representing Finite Set Partitions 1

On the Density of Languages Representing Finite Set Partitions 1 2 3 47 6 23 Journal of Integer Sequences, Vol. 8 2005, Article 05.2.8 On the Density of Languages Representing Finite Set Partitions Nelma Moreira and Rogério Reis DCC-FC & LIACC Universidade do Porto

More information

A REFINED ENUMERATION OF p-ary LABELED TREES

A REFINED ENUMERATION OF p-ary LABELED TREES Korean J. Math. 21 (2013), No. 4, pp. 495 502 http://dx.doi.org/10.11568/kjm.2013.21.4.495 A REFINED ENUMERATION OF p-ary LABELED TREES Seunghyun Seo and Heesung Shin Abstract. Let T n (p) be the set of

More information

Expected Number of Distinct Subsequences in Randomly Generated Binary Strings

Expected Number of Distinct Subsequences in Randomly Generated Binary Strings Expected Number of Distinct Subsequences in Randomly Generated Binary Strings arxiv:704.0866v [math.co] 4 Mar 08 Yonah Biers-Ariel, Anant Godbole, Elizabeth Kelley March 6, 08 Abstract When considering

More information

Chapter 5 Divide and Conquer

Chapter 5 Divide and Conquer CMPT 705: Design and Analysis of Algorithms Spring 008 Chapter 5 Divide and Conquer Lecturer: Binay Bhattacharya Scribe: Chris Nell 5.1 Introduction Given a problem P with input size n, P (n), we define

More information

On the Average Complexity of Brzozowski s Algorithm for Deterministic Automata with a Small Number of Final States

On the Average Complexity of Brzozowski s Algorithm for Deterministic Automata with a Small Number of Final States On the Average Complexity of Brzozowski s Algorithm for Deterministic Automata with a Small Number of Final States Sven De Felice 1 and Cyril Nicaud 2 1 LIAFA, Université Paris Diderot - Paris 7 & CNRS

More information

PROBABILISTIC BEHAVIOR OF ASYMMETRIC LEVEL COMPRESSED TRIES

PROBABILISTIC BEHAVIOR OF ASYMMETRIC LEVEL COMPRESSED TRIES PROBABILISTIC BEAVIOR OF ASYMMETRIC LEVEL COMPRESSED TRIES Luc Devroye Wojcieh Szpankowski School of Computer Science Department of Computer Sciences McGill University Purdue University 3450 University

More information

On rational approximation of algebraic functions. Julius Borcea. Rikard Bøgvad & Boris Shapiro

On rational approximation of algebraic functions. Julius Borcea. Rikard Bøgvad & Boris Shapiro On rational approximation of algebraic functions http://arxiv.org/abs/math.ca/0409353 Julius Borcea joint work with Rikard Bøgvad & Boris Shapiro 1. Padé approximation: short overview 2. A scheme of rational

More information

Introduction to Techniques for Counting

Introduction to Techniques for Counting Introduction to Techniques for Counting A generating function is a device somewhat similar to a bag. Instead of carrying many little objects detachedly, which could be embarrassing, we put them all in

More information

Algorithms Design & Analysis. Analysis of Algorithm

Algorithms Design & Analysis. Analysis of Algorithm Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of

More information

SPECIAL POINTS AND LINES OF ALGEBRAIC SURFACES

SPECIAL POINTS AND LINES OF ALGEBRAIC SURFACES SPECIAL POINTS AND LINES OF ALGEBRAIC SURFACES 1. Introduction As we have seen many times in this class we can encode combinatorial information about points and lines in terms of algebraic surfaces. Looking

More information

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms

More information

Generating All Circular Shifts by Context-Free Grammars in Chomsky Normal Form

Generating All Circular Shifts by Context-Free Grammars in Chomsky Normal Form Generating All Circular Shifts by Context-Free Grammars in Chomsky Normal Form Peter R.J. Asveld Department of Computer Science, Twente University of Technology P.O. Box 217, 7500 AE Enschede, the Netherlands

More information

A New Algorithm to Compute Terms in Special Types of Characteristic Sequences

A New Algorithm to Compute Terms in Special Types of Characteristic Sequences A New Algorithm to Compute Terms in Special Types of Characteristic Sequences Kenneth J. Giuliani 1 and Guang Gong 2 1 Dept. of Mathematical and Computational Sciences University of Toronto at Mississauga

More information

Combinatorial/probabilistic analysis of a class of search-tree functionals

Combinatorial/probabilistic analysis of a class of search-tree functionals Combinatorial/probabilistic analysis of a class of search-tree functionals Jim Fill jimfill@jhu.edu http://www.mts.jhu.edu/ fill/ Mathematical Sciences The Johns Hopkins University Joint Statistical Meetings;

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 1 Data Structures and Algorithms Chapter 3 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

PROBABILITY VITTORIA SILVESTRI

PROBABILITY VITTORIA SILVESTRI PROBABILITY VITTORIA SILVESTRI Contents Preface. Introduction 2 2. Combinatorial analysis 5 3. Stirling s formula 8 4. Properties of Probability measures Preface These lecture notes are for the course

More information

Algorithmic Approach to Counting of Certain Types m-ary Partitions

Algorithmic Approach to Counting of Certain Types m-ary Partitions Algorithmic Approach to Counting of Certain Types m-ary Partitions Valentin P. Bakoev Abstract Partitions of integers of the type m n as a sum of powers of m (the so called m-ary partitions) and their

More information

Analysis of Algorithms - Using Asymptotic Bounds -

Analysis of Algorithms - Using Asymptotic Bounds - Analysis of Algorithms - Using Asymptotic Bounds - Andreas Ermedahl MRTC (Mälardalens Real-Time Research Center) andreas.ermedahl@mdh.se Autumn 004 Rehersal: Asymptotic bounds Gives running time bounds

More information

Recurrence Relations

Recurrence Relations Recurrence Relations Winter 2017 Recurrence Relations Recurrence Relations A recurrence relation for the sequence {a n } is an equation that expresses a n in terms of one or more of the previous terms

More information

Powers of Tensors and Fast Matrix Multiplication

Powers of Tensors and Fast Matrix Multiplication Powers of Tensors and Fast Matrix Multiplication François Le Gall Department of Computer Science Graduate School of Information Science and Technology The University of Tokyo Simons Institute, 12 November

More information

5. DIVIDE AND CONQUER I

5. DIVIDE AND CONQUER I 5. DIVIDE AND CONQUER I mergesort counting inversions closest pair of points randomized quicksort median and selection Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

CPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication

CPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication CPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication March, 2006 1 Introduction We have now seen that the Fast Fourier Transform can be applied to perform

More information

Counting patterns in digital expansions

Counting patterns in digital expansions Counting patterns in digital expansions Manfred G. Madritsch Department for Analysis and Computational Number Theory Graz University of Technology madritsch@math.tugraz.at Séminaire ERNEST Dynamique, Arithmétique,

More information

Generating All Permutations by Context-Free Grammars in Chomsky Normal Form

Generating All Permutations by Context-Free Grammars in Chomsky Normal Form Generating All Permutations by Context-Free Grammars in Chomsky Normal Form Peter R.J. Asveld Department of Computer Science, Twente University of Technology P.O. Box 217, 7500 AE Enschede, the Netherlands

More information

COMP 355 Advanced Algorithms

COMP 355 Advanced Algorithms COMP 355 Advanced Algorithms Algorithm Design Review: Mathematical Background 1 Polynomial Running Time Brute force. For many non-trivial problems, there is a natural brute force search algorithm that

More information

CIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23

CIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23 CIS 11 Data Structures and Algorithms with Java Spring 018 Big-Oh Notation Monday, January /Tuesday, January 3 Learning Goals Review Big-Oh and learn big/small omega/theta notations Discuss running time

More information

Alternative Combinatorial Gray Codes

Alternative Combinatorial Gray Codes Alternative Combinatorial Gray Codes Cormier-Iijima, Samuel sciyoshi@gmail.com December 17, 2010 Abstract Gray codes have numerous applications in a variety of fields, including error correction, encryption,

More information

FINITE ABELIAN GROUPS Amin Witno

FINITE ABELIAN GROUPS Amin Witno WON Series in Discrete Mathematics and Modern Algebra Volume 7 FINITE ABELIAN GROUPS Amin Witno Abstract We detail the proof of the fundamental theorem of finite abelian groups, which states that every

More information

NON-FRINGE SUBTREES IN CONDITIONED GALTON WATSON TREES

NON-FRINGE SUBTREES IN CONDITIONED GALTON WATSON TREES NON-FRINGE SUBTREES IN CONDITIONED GALTON WATSON TREES XING SHI CAI AND SVANTE JANSON Abstract. We study ST n, the number of subtrees in a conditioned Galton Watson tree of size n. With two very different

More information

Weak Heaps and Friends: Recent Developments

Weak Heaps and Friends: Recent Developments Weak Heaps and Friends: Recent Developments Stefan Edelkamp 1, Amr Elmasry 2, Jyrki Katajainen 3,4, 1) University of Bremen 2) Alexandria University 3) University of Copenhagen 4) Jyrki Katajainen and

More information

Space Complexity of Algorithms

Space Complexity of Algorithms Space Complexity of Algorithms So far we have considered only the time necessary for a computation Sometimes the size of the memory necessary for the computation is more critical. The amount of memory

More information

Asymptotic Algorithm Analysis & Sorting

Asymptotic Algorithm Analysis & Sorting Asymptotic Algorithm Analysis & Sorting (Version of 5th March 2010) (Based on original slides by John Hamer and Yves Deville) We can analyse an algorithm without needing to run it, and in so doing we can

More information

The Number of Inversions in Permutations: A Saddle Point Approach

The Number of Inversions in Permutations: A Saddle Point Approach 1 2 3 47 6 23 11 Journal of Integer Sequences, Vol. 6 (23), Article 3.2.8 The Number of Inversions in Permutations: A Saddle Point Approach Guy Louchard Département d Informatique CP 212, Boulevard du

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

More information

with the size of the input in the limit, as the size of the misused.

with the size of the input in the limit, as the size of the misused. Chapter 3. Growth of Functions Outline Study the asymptotic efficiency of algorithms Give several standard methods for simplifying the asymptotic analysis of algorithms Present several notational conventions

More information

6.854 Advanced Algorithms

6.854 Advanced Algorithms 6.854 Advanced Algorithms Homework Solutions Hashing Bashing. Solution:. O(log U ) for the first level and for each of the O(n) second level functions, giving a total of O(n log U ) 2. Suppose we are using

More information

Estimates for probabilities of independent events and infinite series

Estimates for probabilities of independent events and infinite series Estimates for probabilities of independent events and infinite series Jürgen Grahl and Shahar evo September 9, 06 arxiv:609.0894v [math.pr] 8 Sep 06 Abstract This paper deals with finite or infinite sequences

More information

Divide and Conquer. Andreas Klappenecker. [based on slides by Prof. Welch]

Divide and Conquer. Andreas Klappenecker. [based on slides by Prof. Welch] Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch] Divide and Conquer Paradigm An important general technique for designing algorithms: divide problem into subproblems recursively

More information