You are on page 1of 2

Special Assignment (Midterm) Solution

Question 1 Solution

a)

b)

I. 111
II. 1000
III. 1001
IV. 1011

M is outputting the next binary number (successor).

Question 2 Solution

1) Algo B is asymptotically more efficient. At n=451 value of 100nlogn is 405900 whereas value of 2n2
= 406802.
2) Algo A is asymptotically more efficient. At n=23 value of n5 is 6436343 whereas value of 2n is 8388608
3) Algo B is asymptotically more efficient. At n=1001 value of 5n is 5005 whereas value of 500 logn is
5000.
Question 3 Solution

The number of b-incompressible strings of length n is at least 2n − 2 n−b+1 + 1

a) For n = 7, there are at least 27 − 2 7−2+1 + 1 = 65 2-incompressible strings.


b) For n = 8, there are at least 28 − 2 8−4+1 + 1 = 225 4-incompressible strings.
c) For n = 6, there are at least 26 − 2 6−3+1 + 1 = 49 3-incompressible strings.

Question 4 Solution

a) To see how the algorithm is not polynomial time in input size we have to see how the input is
encoded. In binary form the input n is a k-bit binary number. The loop runs 2k times and hence its
exponential in the size (k bits) of input.

b) A non-deterministic Turing machine(NTM) that can accept composite numbers binary uses
following steps

1. On input <n> let k be number of bits in n


2. Guess k bit number p
3. Guess k bit number q
4. If pq=n and p,q > 1 then accept . else reject.

Every composite will be accepted by some branch of computation of NTM. The length of any
branch of computation is polynomial in number of bits so this is a non-deterministic polynomial
time algorithm that accepts composite numbers.

Even though we can solve this composite number problem on NTM in polynomial time, NTM is just
a conceptual mathematical model and no real world computer corresponding to NTM can be
created so we cannot use NTM polynomial time algorithm on real computers.

You might also like