• Non ci sono risultati.

Algorithm Engineering 09 June 2014

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 09 June 2014"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering

09 June 2014

1. [rank 5] Describe the Snow Plow algorithm, comment in which sorting algorithm can be used and how it is used, and simulate its working over the sequence 3,8,1,5,1,4,2, and show which sorted blocks it forms with a memory capable to store M=2 integers.

1. [rank 5] Let us given symbols and probabilities: p(a) = 0.5, p(b)=p(c) = 0.25.

Decompress the first 4 symbols of the Arithmetic coded bit sequence: 10111.

2. [rank 4+5]

a. Given a universal hash function h: U  {0,1, …, m-1}, show that the average list length in a hash table T with chaining based on h is O(n/m), whenever a given set S of size n is inserted in T.

b. Assume you are given 6 strings (aa, ab, bb, bc, ca, db) and you wish to construct a minimal ordered perfect hash function. Assume that

rank(x)=1,2,3,4 for the characters x=a,b,c,d respectively. Given a string x’x’’ of two characters, we let the two random functions required by the design of MOPHF as h1(x’ x’’) = 2 * rank(x’) * rank(x’’) mod 13 and h2(x’ x’’) = rank(x’) + rank(x’’) + 1 mod 13 (so m=13). Design a proper g(t) to construct the final h(t), if this is possible given h1 and h2 above.

3. [rank 3+4+4] Given the graph G = {(a,b) (a,d) (b,c) (c,a) (c,e) (d,b) (d,e) (e,c) }

a. Perform a BFS visit of G, specifying the edges and nodes in the order they are visited (assume that the adjacency list of each node is sorted by destination-node label).

b. Build the MST of G via Kruskal’s algorithm, assuming that the weight of the edge (x,y) is computed as rank(x) * rank(y) mod 7, and rank(x) is the rank in the alphabet of letter x, counting from 2.

c. Prove that in a random undirected graph of y edges and x = 2 * c * y nodes, where c>1 is a constant, the probability that the shortest path between two given nodes is of length L is < c^{-L}/x.

Riferimenti

Documenti correlati

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

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

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

Compute the Shortest Path Tree from node a using Dijkstra’s algorithm (showing all steps and used data structures)b. Show how to compute the MST of G in the case of an internal memory

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