Second Semester Examinations 2016/2017: Answer FOUR Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

PAPER CODE NO. EXAMINER : Leszek A.

Gasieniec
˛ Tel. No. 7954290
COMP526 DEPARTMENT : Computer Science

SECOND SEMESTER EXAMINATIONS 2016/2017

Applied Algorithmics

TIME ALLOWED : Two and a Half Hours

INSTRUCTIONS TO CANDIDATES

Answer FOUR questions.


If you attempt to answer more questions than the required number of questions (in any section),
the marks awarded for the excess questions answered will be discarded (starting with your
lowest mark).

PAPER CODE COMP526 page 1 of 6 Continued


Question 1

1.A Consider a sequence of bits D = D3 D2 D1 D0 = 0000 that is to be sent


across a noisy communication channel.
• Compute parity bits P2 , P1 and P0 and interleave them with the bits of the
sequence D according to the rules of the error detection mechanism, which
is based on parity of subsets of bits (8 marks).
• Explain also how one can discover that a bit of D, e.g., D1 , flipped from 0
to 1 during transmission through the communication channel (7 marks).
[Total: 15 marks]

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.

1. Determine the contents of words w5 and s5 (1 mark) and compute wit-


nesses against all non-periods in both of them (2 marks).
2. What is the longest shared string in pairs wi and si , for i ≥ 5?(4 marks)

[Total: 7 marks]

1.C Explain the concept of amortised analysis and provide two examples of its
use. [Total: 3 marks]

PAPER CODE COMP526 page 2 of 6 Continued


Question 2

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.

• Associate provided probabilities with symbols in A (5 marks).


• Explain whether the structure of the Huffman tree (and the code) will change
if the probabilitity 0.05 is lifted to 0.10 and 0.25 reduced to 0.20 resulting
in the new distribuiton 0.10, 0.15, 0.20, 0.20, and 0.35 (5 marks).
• Comment briefly on the time complexity of the Huffman code construction
(2 marks) and compute the bit rate of the codes before and after amend-
ment of probabilities (3 marks).

[Total: 15 marks]

2.B Let O = (6, 4, 1, 2, 5, 1, 6, 3, 5, 6, 4, 4) and Q = [S, A, G, E, V, L, I] be re-


spectively the output sequence of indexes and the content of the queue of sym-
bols after application of MTF (Move-to-Front) algorithm on the input sequence
S. Recover the content of S (3 marks) and trace the content of Q throughout
execution of inverse MTF (Move-to-Front) algorithm (4 marks).

[Total: 7 marks]

2.C Provide the definition of ε-tester and discuss in brief its application.

[Total: 3 marks]

PAPER CODE COMP526 page 3 of 6 Continued


Question 3

3.A Consider a partially filled in array A[0..15] with integer keys, see Figure 1.

n=16 processing units

P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15

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

Array A[0..n-1], for n=16

Figure 1: The input array A

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]

3.B A stream starting with symbols BACBACCABCABBACBAC... forms


the input to the Misra-Gries algorithm for computing the two very frequent items.
Explain the principles of the Misra-Gries algorithm (3 marks) and determine the
contents of the two counters after scanning two prefixes BACBACCA as well
as BACBACCABCAB from the input stream.

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

PAPER CODE COMP526 page 4 of 6 Continued


Question 4

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]

PAPER CODE COMP526 page 5 of 6 Continued


Question 5

5.A Explain briefly the mechanism used in the Burrows-Wheeler Transform


(BWT) procedure (3 marks). Consider an infinite language in which the kth
word wk = (ab)k+1 ak , for all integers k ≥ 0. Compute first w0 , w1 and w2
(2 marks) and generate BW T (w2 ) (3 marks). Explain also what is the struc-
ture of BW T (wk ) for large values of k (7 marks).
[Total: 15 marks]

5.B Consider an instance of the Combinatorial Group Testing (CGT) Problem,


where a collection C of 8 items I1 , I2 , . . . , I10 is tested for having a property
P. The results of 7 tests performed on subsets of items in C are represented as
the feedback vector in Figure 2. Explain which items from the collection have
the property P (5 marks) and which of them are still suspected to possess the
property P (2 marks) on the conclusion of the round of 7 tests.

T EST # / I TEMS : I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 F EEDBACK VECTOR

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

Figure 2: The round of 7 tests and the feedback vector.

[Total: 7 marks]

5.C Explain what are the basic principles of the loop invariant method.
[Total: 3 marks]

PAPER CODE COMP526 page 6 of 6 End

You might also like