Second Semester Examinations 2016/2017: Answer FOUR Questions
Second Semester Examinations 2016/2017: Answer FOUR Questions
Second Semester Examinations 2016/2017: Answer FOUR Questions
Gasieniec
˛ Tel. No. 7954290
COMP526 DEPARTMENT : Computer Science
Applied Algorithmics
INSTRUCTIONS TO CANDIDATES
1.B The Fibonacci Language F = {w0 , w1 , w2 , ...} is defined over the binary
alphabet A = {a, b}, where w0 = a, w1 = b, and wi = wi−1 · wi−2 , for all
integer i ≥ 2. Similarly one can define the negation of the Fibonacci Language
as F ∗ = {s0 , s1 , s2 , ...}, where s0 = b, s1 = a, and si = si−1 · si−2 , for all integer
i ≥ 2.
[Total: 7 marks]
1.C Explain the concept of amortised analysis and provide two examples of its
use. [Total: 3 marks]
2.A Let alphabet A = {A, B, C, D, E}, where the symbols in A have the follow-
ing representation in the Huffman code: A = 01, B = 000, C = 11, D = 001,
and E = 10. We know that the probabilities of symbols in increasing order are
0.05, 0.15, 0.20, 0.25, and 0.35, however, we do not know what is the probability
of each symbol in A individually.
[Total: 15 marks]
[Total: 7 marks]
2.C Provide the definition of ε-tester and discuss in brief its application.
[Total: 3 marks]
3.A Consider a partially filled in array A[0..15] with integer keys, see Figure 1.
1 0 0 1 1 0 0 2 0 0 0 3 0 5 0 8
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Show the consecutive steps of the parallel prefix-sums procedure computing pre-
fix sums (counting from the left) for each non-zero integer key. Assume you
have16 processing units P (i), s.t., P (i) is associated with the memory cell A[i],
for i = 0, .., 15 (10 marks). Comment briefly on the time and the work com-
plexity of the prefix-sums procedure for input arrays of an arbitrary size n (3
marks) and explain how the work optimality of this procedure can be obtained
(2 marks).
[Total: 15 marks]
[Total: 7 marks]
3.C What is the main mechanism used in the effcient solution to pattern matching
with “don’t care” symbols. [Total: 3 marks]
4.A Draw a suffix tree (5 marks) and its compact counterpart (4 marks) for the
input string babaabbb and create the respective suffix array (4 marks) for the
same input string. Comment briefly on sizes of compact suffix trees and suffix
arrays for strings built over constant size alphabets (2 marks).
[Total: 15 marks]
4.B Explain the main differences between sequential merge-sort and quick-sort
procedures (4 marks). Comment briefly on the time complexity of both proce-
dures (3 marks).
[Total: 7 marks]
4.C Explain what are the basic operations defined on stacks and what is their
time complexity.
[Total: 3 marks]
1 0 0 0 1 0 1 1 0 0 0 1
2 1 0 0 1 0 0 0 1 0 1 0
3 0 0 0 0 0 0 0 0 0 0 0
4 0 0 1 0 0 1 0 0 0 1 0
5 0 0 0 1 1 0 0 0 0 1 0
6 0 1 0 0 1 0 1 0 1 0 1
7 1 1 1 1 1 1 1 1 1 1 1
[Total: 7 marks]
5.C Explain what are the basic principles of the loop invariant method.
[Total: 3 marks]