• Non ci sono risultati.

Algorithm Engineering 15 June 2018

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 15 June 2018"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering 15 June 2018

Exercise [rank 4+4]

1. Write the pseudo-code of the Reservoir Sampling algorithm that random samples m items from a sequence of unknown length.

2. Simulate the algorithm of point 1 by drawing m=2 items from a sequence of length n=8: [a, b, c, d, e, f, g, h], and assuming that at every step the random integers extracted by the algorithm are [3, 1, 2, 2, 1, 5].

Exercise [rank 5]

Let us given symbols and probabilities: p(a) = 0.2, p(b)=p(c) = 0.4. Compress the first 3 symbols of the text T = ABC via Arithmetic code.

Exercise [rank 5]

Assume you are given a set of 6 strings {aa, ad, bc, bd, ca, dc} and you wish to construct a minimal ordered perfect hash function, where the order is the alphabetic one.

Assume that rank(x)=3,4,5,6 for the characters x=a,b,c,d respectively. Given a string x’x’’ of two characters, we let the two random functions required by the design of MOPHF as h1(x’ x’’) = 3 * rank(x’) * rank(x’’) mod 13 and h2(x’ x’’) = rank(x’) + rank(x’’) mod 13 (so m=13). Design a proper g(t) to construct the final h(t), if this is possible, given h1 and h2 above.

Exercise [rank 4+4+4] Three theoretical questions

 Show the pseudo-code of the variant of binary quicksort that reduces the extra- space used during recursive calls, and comments on its complexity and

correctness.

Prove that the search for a key in the skip list takes O(log n) time

 Prove that Arithmetic coding is two bits from the optimal lower bound given by the entropy of a string/source.

Riferimenti

Documenti correlati

 Infer, via the formulas about (S,C)-dense codes, how many bits are needed for the

Finally simulate its working over the sequence 3,10,1,6,2,5,3, by showing the sorted blocks it forms with a memory capable to store M=2 integers.. Exercise

Exercise [lode] Describe when the “strange case” of LZW occurs and how it is solved by the decompression algorithm, by providing also a

Write the pseudo-code of the algorithm that random samples m items from a sequence of known length n by means of a scanning approach. 2) design an algorithm that solves, via

 Show the pseudo-code of the variant of binary quicksort that reduces the extra- space used during recursive calls, and comments on its complexity

[rank 5] Describe the Snow Plow algorithm, comment in which sorting algorithm can be used and how it is used, and simulate its working over the sequence 3,8,1,5,1,4,2, and show

Since it will be possible to produce computations without recalculations that evaluate −→ G V using memory space m (e.g., the bottom up execution by levels starting from the leaves),

Nell’ambito di tale prospettiva la Commissione Europea nel dicembre 2004 ha adottato una Deci- sione relativa all’istituzione di un “quadro unico” per la trasparenza delle