• Non ci sono risultati.

Algorithm Engineering 19 November 2019 [First midterm]

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 19 November 2019 [First midterm]"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering

19 November 2019 [First midterm]

Name: Surname: Matricola:

Exercise [rank 5] Show the execution of Minimal Ordered Perfect Hashing over the set of strings S = {AA, BB, BD, CD} where the two hash functions applied to the bigram xy have been defined as

h1(xy) = 3 * rank(x) + rank(y) mod 7 h2(xy) = rank(x) + rank(y) mod 7,

and character’s rank for {A,B,C,D} is evaluated respectively as {1, 2, 3, 4}.

Exercise [rank 5] Show the execution of the Snow Plow algorithm over the sequence of keys (1, 2, 3, 9, 6, 0, 8, 5, 4), by assuming that the memory is able to store 3 items.

Exercise [rank 5] Build a Ternary Search Tree by inserting the following strings according to the given sequence (CAR, CAT, CAB, COD, APE).

Exercise [rank 3] Given a directed graph G with n nodes and m edges, represented via a list of pairs (i,j) stored contiguously on disk and representing edges i  j, and given a path P specified as (u1, *, u3, *, u5, *, …., u2k+1) consisting of k+1 distinct nodes (explicitly given) and k placeholders * which represent anyone single node,

design an algorithm that establishes whether G includes the path P, and evaluate its I/O-complexity.

Exercise [rank 4+4+4] Answer to the following questions

1. State and prove the lower bound for sorting n items in the two-level memory model with parameters M (internal memory) and B (disk-page size).

2. State and prove the average time bound of the Multi-Key Quicksort for a set of n strings having total distinguishing prefix d and total length N.

3. State and prove the average height of a skip list built on n items.

Riferimenti

Documenti correlati

THEOREM 5.2 Permuting n items takes O(min {n, B n log M/B M n }) I/Os in a two-level memory model in which the internal memory has size M and the disk page has size B.. In what

Prove that the probability of having a 0 in a position of the binary array of the Bloom Filter is ½, when the number of hash functions is set to the optimal one.. (hint: derive

A running example of LSD-first RadixSort is given in Figure 6.4: the red digits (characters) are the ones that are going to be sorted in the current phase, whereas the green digits

THEOREM 4.2 Permuting n items takes O(min {n, B n log M/B M n }) I/Os in a two-level memory model in which the internal memory has size M and the disk page has size B.. In what

A running example of LSD-first RadixSort is given in Figure 5.5: the red digits (characters) are the ones that are going to be sorted in the.. current phase, whereas the green

Suppose that we solve the continuous relaxation of a STSP with a limited number of subtour elimination constraints, and let x ∗ R ∈ [0, 1] |E| be an optimal solution.. Then the

THEOREM 4.2 Permuting n items takes O(min{n, n B log M/B n/M}) I/Os in a two-level model in which the internal memory has size M and the disk page has size B. In what follows we

One immediately sees that the lower the frequency cutoff, the smaller the collapse effect and the longer it takes to reach the same reduction rate as for the white noise case.. 1: