• Non ci sono risultati.

Algorithm Engineering 09 February 2015 Exercise [rank 4+4]

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 09 February 2015 Exercise [rank 4+4]"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering

09 February 2015 Exercise [rank 4+4]

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 an integer (possibly not prime, in order to manage the functions of the second level).

Prove that the space taken by a perfect hash table is linear in the number of keys.

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 block boundaries (hence, no the queries internal into blocks). Finally, show how it is answered the query RMQ[1,6], where indices in A start from 0.

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)}.

 Compute the MST via the Kruskal’s algorithm

 Compute the MST via the Prim’s algorithm

Show all steps of each algorithm e the content of the used data structures.

Exercise [points 2+3+3] Given the string S=ababca, construct its suffix array and then show how it is executed the search and listing of the occurrences of the pattern P=ab. Show also the time and space complexity of the proposed solution.

Riferimenti

Documenti correlati

Le consegne saranno lette dall’insegnante procedendo con un item alla volta senza dare altre interpretazioni e lasciando poi il tempo per eseguire.. Per ogni esercizio ( esclusi

L’obiettivo è collegare ogni isola con ponti orizzontali o verticali in modo che abbia un numero di ponti corrispondente al numero dato e si formi un percorso che colleghi

Simulate the behavior of the algorithm MultiKey-Quicksort on the following array of 6 strings S=[zoo, horse, bath, abacus, bar, aargh].. Exercise

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

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

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

Discuss the solution, assuming that the distinct items are m < M, but their total length mL > M (so you cannot explicitly store them in memory), and comment on its

Perform the calculation in the microcanonical ensemble at fixed total energy, calculate the entropy.. Plot the dimensionless entropy per spin (-// ) !) as a function of a