• Non ci sono risultati.

Algorithm Engineering 12 September 2013 Exercise [rank 5]

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 12 September 2013 Exercise [rank 5]"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering

12 September 2013 Exercise [rank 5]

Construct a perfect hash table for the set of keys {1, 4, 6, 8, 2, 9, 11, 16, 18}, by assuming a first-level table of size 5 and by defining hash functions of the form h(x) = a * x + b mod m, where m is a number (possibly not prime, in order to manage the functions of the second level).

Exercise [rank 3+2]

1) Indicate the optimal upper bounds for the two problems Permuting and Sorting in the RAM and in the External-memory models of computation.

2) Indicate whether it would be preferable to have a larger B or a larger M in order to improve the performance of an algorithm, and comment this answer in the light of point 1.

Exercise [rank 3+4+3+4]

Given the string T = babac,

1. construct its suffix tree ST (hint: you do not need to add $ at the end)

2. show how to derive from ST, the Suffix Array and the LCP array of T in linear O(|T|) time. Depict the algorithm and show its execution on ST of point 1.

3. describe an algorithm which, given a suffix SA[i], returns the suffix SA[j] of T which shares the LCP with SA[i] (hint: it can be solved in O(1) time)

4. construct the Cartesian Tree of the LCP array of point 2 (hint: it was used in class for supporting the RMQ-query over LCP)

Exercise [rank 3+3]

Given the undirected and weighted graph G={(A,B, 4), (A,F, 5), (A,E, 6), (B,C, 6), (B,F, 8), (C,D, 7), (C,F, 5), (D,F, 3), (D,E, 4)}.

 Compute the MST via the Kruskal’s algorithm

 Compute the MST via the Prim’s algorithm Show all steps of each algorithm.

Exercise [rank *]

Prove that the expected reconstruction time of a cuckoo hash table is O(n), if it is built over n items and we consider a sequence of a*n insertions, where a is a constant.

Riferimenti

Documenti correlati

Write the pseudo-code of the Reservoir Sampling algorithm that random samples m items from a sequence of unknown length. Prove that the probability of extracting any element when

Assuming that S is on disk and the Patricia trie is in internal memory, with leaf pointers to strings of S, show the I/O-complexity of prefix- searching for a pattern P[1,p]c. [rank

 discuss the efficiency of PRIM’s algorithm when the graph grows in

Exercise [rank 4] Describe the skip list data structure and state its time complexity for searching, inserting or deleting items in a set of size n..  Show a skip list over the

Exercise [rank 5] Discuss the optimality of the disk striping technique in combination with multi-way mergesort when sorting N items over D disks, in a model with.. internal memory

Exercise [rank 4+4] Let us given two arrays: A[1,n] of items and [1,n] that denotes the permutation of the positions in the range [1,n], such that [i] is the position where the

Exercise [rank 2+2] Provide the motivation of introducing Universal Hashing, with respect to classic hash functions (such as mod, division,…) and an example of family of

Exercise [points 4+4] Given the array A = [5, 2, 4, 8, 3, 1, 9, 6], build the RMQ data structure but ONLY for RMQ-queries which are either aligned to blocks or overlap