• Non ci sono risultati.

Algorithm Engineering 2 September 2016

N/A
N/A
Protected

Academic year: 2021

Condividi "Algorithm Engineering 2 September 2016"

Copied!
1
0
0

Testo completo

(1)

Algorithm Engineering 2 September 2016

Exercise [rank 3+4+6+3] Consider the problem which requires to compute the intersection between two sorted sets A and B of size n and m respectively, m < n.

Propose a solution taking O(n+m) time.

Propose a solution taking O(m log n) time.

Propose a solution taking O(m (1 + log n/m)) time.

Show that the last time bound is optimal in the comparison model.

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 set S={1, 5, 7, 9, 10, 11, 15} assuming that the coin tosses where the following ones for each item: 1-HHT, 5-T, 7-HT, 9-HHHHT, 10- HT, 11-HHHT, 15-HHHHHT.

 Show how to search for the item 10 in that skip list

 Prove that the average depth of the skip list is O(log n)

Exercise [rank 6+4] Given a tree T of size n,

describe a data structure that takes O(n log n) space and solves Lowest- Common-Ancestor (LCA) queries among pairs of leaves of T in O(1) time.

[warning: notice that the space is O(n log n) and not the optimal one O(n)]

 Apply the proposed solution over the tree rooted in 1 and defined by the following edges: (1,2); (1,3); (1,4); (2,5); (3,6); (3,7).

Exercise [lode] State and prove the lower bound for sorting n items in a disk- memory system.

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

Assuming that S is on disk and the Patricia trie is in internal memory, with leaf pointers to strings of S, show the I/O-complexity of prefix- searching for a pattern P[1,p]c. [rank

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

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

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 &lt; M, but their total length mL &gt; M (so you cannot explicitly store them in memory), and comment on its