• Non ci sono risultati.

Algorithm Engineering 19 July 2016

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 19 July 2016"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering 19 July 2016

Exercise [rank 4+3]

1. Write the pseudo-code of the Reservoir Sampling algorithm that random samples m items from a sequence of unknown length.

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 random integers extracted by the algorithm are [3, 4, 1, 2, 1, 5].

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+4+3] Given a set S of 2D points {(1,6), (2,7), (3,8), (4,1), (5,5), (6,1)}, 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 (Treap by max-priority in the root).

2) design an algorithm that determines efficiently, via only splits and top or delete keys, the 2D-points that have x-component in the range [a,b], and y- component larger than c (hint: you can look at this query as a sort of three- sided query [a,b] x [c, +infty]).

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

Exercise [rank 3+4] Given a sequence S of n elements, possibly unordered,

write the pseudo-code of a randomized algorithm that receives in input S and an integer k, and selects fast the k-th ranked item of S

evaluate the average time complexity of your algorithm (hint: the avg time complexity of your algorithm should be linear in n)

Riferimenti

Documenti correlati

[r]

Build the suffix tree of the string T

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

Compress via Arithmetic coding the text ABCC, showing the final binary.. sequence representing the

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) design an algorithm that solves, 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 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

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