• Non ci sono risultati.

Algorithm Engineering 27 June 2016

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 27 June 2016"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering 27 June 2016

Exercise [rank 4+3]

1. 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. 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

probabilities p drawn by the algorithm are [0.5, 0.5, 0, 0.5, 1, 0.1, 1].

Exercise [rank 5] Decode the Bzip-encoding 030330 assuming an alphabet {a,b,d}

and a position of 5 for the special symbol # in the BWT, counting from 1. (hint: Recall the compression sequence BWT + MTF with list (a,b,d) and counting from 1 + RLE only on runs of 1)

Exercise [rank 4+5+4] Given a set S of 2D points {(1,7), (2,1), (3,5), (4,1), (5,4), (6,2)}, 1) build a Treap by assuming that the x-component refers to the key and the y-

component refers to the priority of every item.

2) design an algorithm that solves, via only splits and top or delete keys, the three-sided range query [a,b] x [c, +infty] over S. State its space and time complexity.

3) simulate the algorithm of the previous point over the three sided query [2,6] x [3, +infty] of the 2D space.

Exercise [rank 5] Construct a minimal ordered perfect hash for a set of 8 strings {aaa, aab, aba, abb, …, bbb} by assuming hash functions h1(s) = s[1] + 3 * s[2] + 5 * s[3]

mod 11 and h2(s) = (s[1]+s[2]) * 3 + s[3] mod 11 (hence m=11), where s[i] is the i-th character of string s represented as a=2 and b=3.

Exercise [lode] State and prove the lower-bound for the Sorting on a disk model with memory M and page size B.

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

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

Comment on how they are used in that algorithm to compute the

Write the pseudo-code of the Reservoir Sampling algorithm that random samples m items from a sequence of unknown length. 2) design an algorithm that determines efficiently, via

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

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

Exercise [rank 5] Construct a perfect hash for the set of 8 items S={1, 5, 11, 6, 10, 8, 2, 14}, by assuming that the table of the first level has size m=5, and choose all needed