• Non ci sono risultati.

Algorithm Engineering 08 January 2014

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 08 January 2014"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering

08 January 2014

1. [rank 4] Let us given symbols and probabilities: p(f) = p(e) = 0.05, p(c)=p(d) = 0.15, p(b)=0.2, p(a)=0.4. Construct the Canonical Huffman code, showing how it is obtained step-by-step.

2. [rank 3+3] Given a sequence S of n items (n is unknown), and an integer m, show the pseudo-code of the reservoir sampling algorithm which selects m out of n items uniformly at random from S. Then comment its time/space complexity, and prove its correctness.

3. [rank 5] Let H be a class of Universal Hash functions h: U -> {0,1,2,...,m-1} and let S be a subset of U formed by n keys. Prove that, if h is drawn randomly from H, then the average number of collisions induced by h onto the keys of S is upper bounded by n^2/(2*m). [Comment the formulas you write]

4. [rank 3+3] Show the time complexity of RadixSort

a. as a function of the number of strings n, the string length in bits b, and the bit-size r of the block sorted at every step.

b. Then derive the “optimal” size r and comment the resulting time complexity with respect to (1) multi-key quicksort over n strings of length b, or (2) a trie-based sort procedure.

5. [rank 5] Construct a prefect hash table over the sequence of items S = (10, 11, 19, 2, 6, 22, 23, 27, 0, 5, 3 ) where the table of the first level has size 7 and the hash functions are chosen to be of the form h_a(x) = (ax mod m), where m may be any number (even not a prime).

6. [rank 4] Given a cuckoo table of size r and n items to be inserted into it.

Consider the undirected cuckoo-graph induced by this table and those items.

Show the probability that exists a path of length L connecting a node i to a node j, for an arbitrary L, and whoever are i and j.

Riferimenti

Documenti correlati

Simulate the behavior of the algorithm MultiKey-Quicksort on the following array of 5 strings S=[bus, bath, abacus, aargh, cat], by assuming that the pivot string is always the

Prove that, for any pair of positions i and j in the cuckoo table, the probability that the shortest path connecting ij has length L is c^{-L}/r, where r is the number of

Exercise [rank 5] Given the string S=baobab, compute the Suffix Array, and then derive the LCP array by using the linear-time algorithm seen in class, showing the amount of

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

Exercise [rank 6] Prove that the Arithmetic coding algorithm is close to the empirical entropy of a text having length n symbols. Exercise [rank 5] Let us given symbols

[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

[rank 4] Given the string T[1,9]=ddddaabbcc, compute the Canonical Huffman code for the letters of T assuming as probabilities their empirical frequencies in T.. [rank 5] Given

One of the few cases of a decidable interval logic with genuine interval semantics, that is, not re- ducible to point-based semantics, is the propositional logic of