Sie sind auf Seite 1von 35

Q.#. 1.

Show that the Post Correspondence Problem (PCP) is decidable over unary
alphabet.
Solution:
The Post Correspondence Problem (PCP) is decidable over unary alphabet. We can
describe a Turning Machine M that decides unary PCP.
Given unary PCP instance:
 1a1  1an  
  b1  ,............,  bn  
 1   1  
Let us design a TM M as given below:
M = “On Input  a1 , b1 ,............., an ,bn  ”
1. Check if ai  bi for some i. if so, accept.
2. Check if there exist i, j such that ai  bi and ai  bi . If so, accept otherwise
reject.

Q.#. 2. Prove that every t(n)-time k-tape TM has on equivalent O (t 2 ( n))  time single
tape TM.
Solution:
Given a k-tape TM M, we can make 1-tape TM N. N works as follows:
1. On input x, convert input x to #q0#x#, …. #(the start configuration of M).
This configuration says that x is on the first tape. The rest of the tape is
empty and the machine is in q0.
2. In each pass over the tape, change the current configuration to the next one.
3. If an accepting configuration is reached, accept.
4. If a rejecting configuration is reached, Reject.

Now we have to estimate, how much time does N require?


On any input x of length n, we make the following claims:
1. M uses at most t(n) cells of its k-tape.
2. Each configuration has length at most k t(n) = O(t(n)).
3. Each pass of N requires at most O(t(n)) steps.
4. N makes at most t(n) passes on its tape.

This shows that N run in time O (t ( n )  t ( n ))  O (t 2 ( n )) . Here, we use the fact t ( n )  n .


Thus, the machine convert x to the initial configuration. This takes time O(n). So total
time is given below:
O ( n )  O (t 2 ( n ))  O (t 2 ( n ))

Q.#. 3. Show that ATM is not mapping reducible to ETM . In other words show that no
computable function reduces ATM to ETM. (Hint: Use a proof by contradiction
and facts you already know about ATM and ETM.) (10)
Solution:
Recall that ATM is undecidable, but it is recognizable so its complement ATM is not
recognizable. Note that ETM , the complement of ETM is recognizable, and so since
we know ETM is undecidable, It is also not recognizable.
Proof: We give a proof by contradiction.
Assume, it is false that ATM is not mapping reducible to ETM , so ATM  m ETM .
Consider ATM since ATM is mapping reducible to ETM , we immediately get ATM is
mapping reducible to ETM .
Since, ETM is recognizable, ATM is also recognizable, but this is false, Hence a
contradiction.

Q.#. 4. Which of the following pair of numbers are relatively prime? Show the
calculations that lead to your conclusions.
A) 1274 & 10505 B) 7289 & 8029
SOLUTION:
A) For checking the given number 1274 & 10505 that they are relatively prime or
not we use Euclidean algorithm to find Greatest Common Divisor (GCD).

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 1
10505  1274  8  313
1274  313  4  22
313  22 14  5
22  5  4  2
5  2 2 1
2  2 1  0
The greatest common divisor of 105050 and 1274 is 1. There for they are relatively
prime.

B) For checking the given number 7289 & 8029 that they are relatively prime or
not we use Euclidean algorithm to find Greatest Common Divisor (GCD).
8029  7289 1  740
7289  740  9  629
740  629 1  111
629  111 5  74
111  74  1  37
74  37  2  0
The greatest common divisor of 7289 & 8029 is 37. There for they are not relatively
prime.

Q.#. 5. G is a digraph and show that PATH is in Class P. OR Design a polynomial time
algorithm that takes as input a graph G and two vertices s and t and decides if
there is a path from s to t.
Solution:
We have to give a polynomial time algorithm for this problem. That is “Start BFS or
DFS from s and if t appears then there is a path from s to t”.
Algorithm:
1. On input <G,s,t> where G is a digraph,
2. Mark s.
3. Repeat till no additional nodes are marked:
4. Scan the edges of G, if an edge (a,b) is found going from a, marked node a to
an unmarked node b, mark b.
5. If t is marked, accept, otherwise reject.

Now we have to compute the size of input. We know that input size is at least m,
where m is the number of nodes in G. Thus we have to show that algorithm runs in the
time polynomial in m.

The repeat loop can at most run for m time. Each time all the edges are scanned. Since
the number of edges is almost m2, thus step 2 takes at most m2 time. So the total time
is at most m3. Hence, we have shown that PATH is in p.

Q.#. 6. A Turning Machine with stay put instead of left is similar to an ordinary turning
machine, but the transition function has the form:
  Q  T  Q  T   R, S 
At each point the machine can move its head right or left it stay in the same
position.
Show that this turning machine variant in not equivalent to the usual version.
What class of language does this machine recognize?
SOLUTION:
Remembering what it has written on the tap cells to the left of the current head
position is unnecessary, because the TM is unable to return to these cells and read
them.

Using NFA in the actual construction is convenient because it allows E moves which
are useful for simulating the “Stay Put” TM Transition.

The transition function  ' for the NFA is constructed according  .


 First, we set  '( qstart , p )  ( q0 ) , where q0 is the start state of the TM variant.
 Next, we set  '(qstart , i )  (qaccept ) for any i.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 2
 If  ( p, a )  (qaccept , b, w) where w=R or S, we set  '(q pa , E )  {qaccept } .
 If  ( p, a )  (qreject , b, w) where w=R or S, we set  '(q pa , E )  {qreject } .

Q.#. 7. Show that the collection of Turning-recognizable language is closed under


operation of
(i) Union (ii) Concatenation.
SOLUTION:
I. For any two turning recognizable languages L1 and L2, let M1 and M2 be the
TMs that recognizes the union of L1 and L2:

“On input w
Rum M1 and M2 alternatively on w step by step. If either accept, accept. If
both halt and reject, then reject”

If any of M1 and M2 accepts w, M1 will accepts w since the accepting TM will


come to its accepting state after a finite number of steps. Note that if both M1
and M2 reject and either of them does so by looping, then TM will loop.

II. Form any two Turning-recognizable languages L1 and L2, let M1 and M2 are
the TMs that recognize them. We construct a NTM M’ that recognizes the
concatenation of L1 and L2;
“On Input w;
1. None deterministically cut w into two parts w = w1w2.
2. Run M1 on w1. If it halts and reject, reject. If it accepts, go to stage 3.
3. Run M2 on w2. If it accepts, accept. If it halts and reject, reject.”

If there is a way to cut w into two substrings such that M1 accepts the first part
and M2 accepts the second part, w belongs to the concatenation of L1 and L2
and M1 will accept w after a finite number of steps.

Q.#. 8. Let X be the set {1, 2, 3, 4, 5} and Y be the set {6, 7, 8, 9, 10}. We describe the
functions f: X - Y and g: X Y in the following tables.

N F(n) N G(n)
1 6 1 10
2 7 2 9
3 6 3 8
4 7 4 7
5 6 5 6

a. Is f one-to-one? b. Is f onto? c. Is f a correspondence?


d. Is g one-to-one? e. Is g onto? f. Is g a correspondence?
SOLUTION:
a. f is not one-to-one because f(1)=f(3) on the other hand g is one-to-one.
b. f is not onto because there does not exist x belongs to X such that f(x)=10. But g is
onto.
c. g is a correspondence because g is one-to-one and onto. f is not correspondence
because f is not one-to-one and onto.

Q.#. 9. Show that MPCP is undecidable.


Solution:
Assume that MPCP is decidable. Let us say we have a decider R for MPCP. Consider
the following decider S

1. On input < M, w >


2. Construct, p as described in the seven parts.
3. Run R on P .
4. If R accepts, accept.
5. If R rejects, reject.

Then S is a decider for ATM, which is a contradiction to the fact that ATM is
undecidable.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 3
Q.#. 10. If A ≤m B and B is decidable, then A is decidable.
Solution:
Proof: Since B is decidable hence there is a decider M that decides B.
Now, consider the following decider N:

1. On input x
2. Compute y = f(x)
3. Run M on y
4. If M accepts, accept.
5. If M rejects, reject.

Since f is a computable function and M is a decider therefore N is a decider.


Furthermore, x is accepted by N if and only if y is accepted by M. However, y is
accepted by M if and only if y  B .
Since f is a reduction therefore, x  A if and only if y  f ( x )  B . Which implies that
N accepts x if and only if x  A . This shows that N is a decider for A.

Q.#. 11. If A ≤m B and B is Turning Recognizable, then A is Turning Recognizable.


Solution:
Let A ≤m B and let f be the reducibility from A to B, Furthermore, since B is turning
recognizable, there is a TM M such that L(M)=B

Consider N:
“On input x
1. Computer y=f(x)
2. Run M on y
3. if M accepts, accept.”
Then it is easy to see that L(N) = A.

T   i, j , k  | i, j , k  N 
Q.#. 12. Let . Show that T is countable.
Solution:
We need to demonstrate a one-to-one f : T  N . Let f (i, j , k )  2i 3 j 5k . Function f is
one-to-one because a  b, f ( a )  f (b ) . Therefore, T is countable.

Q.#. 13. Let A be a regular expression. Show that A is decidable.


Solution:
1. Proof is actually one line.
2. If we have a decider M that accepts A.
3. We can switch the accept and reject states to make another decider M‟.
4. M‟ accepts. A

Lets recall that a language A is Turing recognizable if there is a TM M such that


L(M) = A.

Q.#. 14. 234 & 399 pair of numbers is relatively prime? Show the calculations that lead to
your conclusions.
Solution:
For checking the given number “234 and 399” that they are relatively prime or not we
use Euclidean algorithm to find Greatest Common Divisor (GCD).
399  234 1  165
234  165  1  69
165  69  2  27
69  27  2  15
27  15 1  12
15  12 1  3
12  3  4  0

The greatest common divisor of “234 and 399” is 3. There for they are not relatively
prime

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 4
Q.#. 15. Show that some true statement in TH(N, +, X) are not provable
Solution:
Consider the following algorithm:
1. On input Ф
2. Enumerate all possible proofs  1 ,....,
3. Check if  i is a proof of Ф. If it is accept.
4. Check if  i is a proof of ¬Ф. if it is reject.

If all true statements are provable then since each statement is either true or false
hence Ф or ≠ Ф is provable. Thus the above algorithm will be a decider for TH(N,+,×)
. This is a contradiction as we have already proved that TH(N,+,×) is not decidable.

Q.#. 16. MINTM is not Turing-Recognizable.


Solution:
Two facts about MINTM.
 MINTM is infinite.
 MINTM contains TM’s whose length is arbitrarily large.
If MINTM is Turing Recognizable then there is a TM E that enumerates MINTM. We
will use E and the recursion theorem to construct another TM C.

On input w
 Obtain own description <C>.
 Run E until a machine D appears with a longer description than that of C.
 Simulate D on input w.

All we have to note that eventually D will appear as MINTM contains TM with
arbitrarily large descriptions. L(C) = L(D).
However, C has a smaller description than D. So D cannot be in MINTM.

Q.#. 17. A={<R>|R is a regular expression describing a language containing at least one
string w that has 111 as substring(i.e.w=x111y for some x,y } show A is
decidable.
Solution:
The following TM X decide A.

X = “On input R where R is regular Expression:


* *
1. Construct DFA E that accepts  111 .
2. Construct DFA B such that L ( B )  L ( R )  L ( E ) .
3. Run TM T on input B where T decides EDFA.
4. If T accepts, reject. If T rejects, accept.”
  ab   b   aba   aa  
 , ,  ,  
  abab   a   b   a  
  ab   ab   aba   b   b   aa   aa  
 , ,  ,   ,   ,   ,  
  abab   abab   b   a   a   a   a  

Q.#. 18. Consider following instance of PCP. Is it possible to find a match? If yes then give
the dominos arrangements. If NO then prove. 1/0. 101/1. 1/001 (5).
Solution:
We can give the number to instances as :
  1  101   1  
  ,  , 
  0   1   001  
 
  1  101   1  
  ,  , 
0   1  
 001
 
 A B C 

We have choice for start matching that is pair B where 1 is at start from top and
bottom so pair B is,

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 5
 
 101  
 
 1  
 B 

Form pair B we can see that 1 is match in top and bottom string but 01 is left in the
upper so we need a pair whose bottom string starts with 0. There are twp pairs A and
C.
   
 101   1    101   1  
 ,   OR   ,  
  1   0   1  
001
 
 B A   B C 
We can not use C because there will be a mismatch so use A.
After using B,A from upper 10 and bottom 10 is matched but 11 is left from upper so
we need a pair whose bottom string starts with 1. That is B.
 
 101  1  101  

 1  ,  0  ,  1   Upper = 101 , Bottom = 101
   
 B A B 

After using B,A,B from upper 101 and bottom 101 is matched but 1101 is left from
upper so we need a pair whose bottom string starts with 1. That is B.
 
 101   1  101  101 

 1  ,  0  ,  1  ,  1   Upper = 1011 , Bottom = 1011
    
 B A B B 

After using B,A,B,B from upper 1011 and bottom 1011 is matched but 101101 is left
from upper so we need a pair whose bottom string starts with 1. That is B.
 
 101   1  101  101 101  
 , , , ,  Upper = 10111 , Bottom = 10111
 1  
0  1  
1  
1  
 B A B B B 

After using B,A,B,B,B from upper 10111 and bottom 10111 is matched but 01101101
is left from upper so we need a pair whose bottom string starts with 0. That is A and C.
If we use C there will a mismatch.
 
 101   1  101  101  101  1  
 , ,
1   0   1  
, ,
1  
,
1   001   Upper = 1011101 , Bottom = 1011100
   
 B A B B B C 
So we use A
 
 101   1  101  101  101   1  

 1  ,  0  ,  1  ,  1  ,  1  ,  0   Upper = 101110 , Bottom = 101110
      
 B A B B B A 
After using B,A,B,B,B,A from upper 101110 and bottom 101110 is matched but
11011011 is left from upper so we need a pair whose bottom string starts with 1. That
is B.
 
 101  1  101  101  101  1  101  

 1  ,  0  ,  1  ,  1  ,  1  ,  0  ,  1  
       
 B A B B B A B 
We observe that Upper Values are increasing, we can not use C having bottom 001
because in upper there will not 00 in it. So, it is not possible to find a match for this
instance.

Q.#. 19. In the silly Post Correspondence Problem, SPCP, in each pair the top string has
the same length as the bottom string. Show that the SPCP is decidable. 10
Solution:
The SPCP problem is decidable. It follows from the following claim.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 6
t 
Claim: A given SPCP instance has a match if and only if there is a domino  i  such
 bi 
that ti  bi .
Proof of the claim:
”  ”: If a SPCP instance has a match it has to start with some domino. Because the
length of the top and the bottom string is the same in all dominos, the first domino in
the match must surely have the same top and bottom string.

”  ”: If there is a domino with the same top and bottom string then this single
domino forms a trivial match of SPCP.

Finally, checking whether there is a domino with the same top and bottom string is
easily decidable by examining the SPCP instance.

Q.#. 20. { [ 10 ], [ 001], [ 01 ] }


00 10 011
Solution:
We can give the number to instances as:
10 001 01
[ ], [ ], [ ]
00 10 011
A B C
We have choice for start matching that is pair C where 0 is at start from top and
bottom so pair C is,
01
[ ]
011
C
Form pair c we can see that 01 is match in top and bottom string but 1 is left in the
bottom so we need a pair whose upper string starts with 1 that is pair A
01 10
[ ],[ ]
011 00
C A
Now 0110 string is match from top and bottom,0 is left from bottom so we need a pair,
who’s upper string starts with 0, there are two choice either select pair B or C. Let’s
first try with pair B,

01 10 001
[ ] ,[ ],[ ]
011 00 10
C A B

01 10 01
[ ] ,[ ],[ ]
011 00 011
C A B

It does not match, so let’s try pair C,

01 10 01
[ ],[ ],[ ]
011 00 011
C A B
Again we have a mismatch. There is no other pair left. So, it is not possible to find a
match for this instance.
Q.#. 21. { [100 ], [ 1 ], [ 0
]}
1 00 100
Solution:
We can give the number to instances as
Numbering the instances as follows:
100   1   0 
 1  ,  00  , 100 
A B C
The dominos arrangement which will gives the matching of top and bottom string is:
A, B, A, A, B, C, C

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 7
100   1  100  100   1   0   0 
 1  ,  00  ,  1  ,  1  ,  00  , 100  , 100 
             

Now if we note the top string that is 1001100100100


If we note bottom string that is 1001100100100
Now the matching is found so this list is called match.

Q.#. 22. { [ 01 ], [100 ], [ 10 ], [ 1


], [
0
]}
100 0 101 010 10
Solution:
We can give the number to instances as :
01 100 10 1 0
[ ], [ ], [ ], [ ], [ ]
100 0 101 010 10
A B C D E
We have choice for start matching that is pair C where 1 is at start from top and
bottom so pair C is,
10
[ ]
101
C
Form pair c we can see that 10 is match in top and bottom string but 1 is left in the
bottom so we need a pair whose upper string starts with 1 that is pair D
10 1
[ ],[ ]
101 101
C D
Now 010 is left from bottom and we need a string that is start from 0 at the top which
is A
10 1 01
[ ],[ ],[ ]
101 010 100
C D A
Now the matching string is 10101, 0100 is left in the bottom , we need string with 0
from top that is E
10 1 01 0
[ ],[ ],[ ],[ ]
101 010 100 10
C D A E
Now matching string is 101010, 10010 is left in the bottom, so the best choice pair B
10 1 01 0 100
[ ],[ ],[ ],[ ],[ ]
101 010 100 10 0
C D A E B
matching is 101010100, 100 is left from bottom

So choose pair B again


10 1 01 0 100 100
[ ],[ ],[ ],[ ],[ ],[ ]
101 010 100 10 0 0
C D A E B B
now 0 is left from bottom so choose pair E
10 1 01 0 100 100 0
[ ],[ ],[ ],[ ],[ ],[ ],[ ]
101 010 100 10 0 0 10
C D A E B B E
now 10 s left from bottom, choose pair B
10 1 01 0 100 100 0 100
[ ],[ ],[ ],[ ],[ ],[ ],[ ],[ ]
101 010 100 10 0 0 10 0
C D A E B B E B
So the matching string is 1010101001000100

Q.#. 23. Now let M2 be the model whose universe is the real numbers R and that assigns
the relation PLUS to R1, where PLUS(a,b,c)=TRUE whenever a+b=c. Then M2 is
a model of . However, if N were used for the
inverse instead of R in M2, the sentence would be false.

SOLUTION:
Theorem: ALLCFG is undecidable.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 8
If ALLCFG is decidable then there is a decider R such that L(R) = ALLCFG
Suppose R decides ALLCFG then consider S
1. On input <M, w>
2. Construct and LBA D as described earlier.
3. Convert D into an equivalent CFG G.
4.. Run R on G. If R accepts reject. If R rejects accepts.

Note that S is a decider for A TM. A contradiction.

Theorem: HALTTM is undecidable.

Suppose that HALTTM is decidable and R decides HALTTM. If we have R then we


have no problem on TM that loop en endlessly.
dlessly. We can always check if a TM will loop
endlessly on a given input using R. We can use R to make a decider for ATM. We
know that ATM is undecidable. We have a contradiction and that is why R cannot
exist.
Given R we can construct S which decides AT ATM that operates as follows:
1. On input <M, w>
2. Run TM R on input <M, w>.
3. If R rejects, reject.
4. If R accepts, simulate M on w until it halts.
5. If M has accepted w, accept; if M has rejected w, reject.

Note that S will reject <M, w> even if M loops on w.

Q.#. 24. Show that half clique is NP


NP-Complete
Solution:

Q.#. 25. Let HALF


HALF-CLIQUE = {(G)| G is an undirected graph having a complete sub- sub
graph with at least m/2 nodes, where m is the number of nodes in (G)}. Show that
HALF--CLIQUE is NP-Complete.
SOLUTION:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 9
Q.#. 26. Let CNFk = {(∅) | ∅is a satisfiable CNF-formula
formula where each variable appears in
at most k places}.
a. Show that CNF2 ∈ P
b. Show that CNF3 is NP-complete.
Solution:

Q.#. 27. Let A = {<M,x,>|NTM, M accepts input x within t steps on at least one branch}.
Show that A is NP Complete.
Solution:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 10
Q.#. 28. Say that two Boolean formulas are equivalent if they have the same set of
variables and are true on the same set of assignments to those variables. A
Boolean formula is minimal if no shorter Boolean formula is equivalent to it. Let
MIN-Formula
Formula be the collection of minimal Boolean formulas. Show that MIN- MIN
FORMULA is in PSPACE.
Solution:
First notice that the language of all pairs of Boolean formulas ((_1;
_1; _2) such that _1 and
_2 are not equivalent is an NP language. We can guess an assignment and check that
the formulas di_er on this assignment in polynomial time. Assuming P=NP, this
language and its complement, the equivalence problem for formulas, are in P.
A formula is not minimal if there exists a smaller formula that is equivalent to it. Thus,
given the above,
MIN-FORMULA
FORMULA 2 NP because we can guess a smaller formula and check
equivalence. Again, assuming
P=NP, we have MIN MIN-FORMULA
FORMULA 2 P. and hence MIN-FORMULA
MIN 2 P.

Q.#. 29. Let TRUE


TRUE-SAT;
SAT; given Boolean expression E that is true when all the variables
are made true, is there some other truth assignment besides all true that make E
true. Show that TURE
TURE-SAT
SAT is NP complete by reducing SAT to it.
Solution:

Q.#. 30. hat, if P=NP, then every language A ∈ P, except A=∅ and A=£*, is NP-
Show that,
Complete.
Solution:

Q.#. 31. Let G represent and undirected graph. Also let LPATH = {<G,a,b,k>|G contains
a simple path of length k for a to b>}. Show that LPATH is NP complete. You
may assume
ssume that NP completeness of UHAMPTH the HAMPATH problem of
undirected graph.
Solution:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 11
Q.#. 32. The 3 SAT problem consists of conjunction of clauses over n Boolean variables
where each clause is dis
dis-junction
junction of 3 literals.
Solution:
The DOUBLE
DOUBLE-SAT problem takes as input a Boolean formula f, and asks if there are
two satisfying assignments for f. Prove that DOUBLE
DOUBLE-SAT
SAT is NP complete by
reduction from 33-SAT.

Q.#. 33. Let PAL


PAL-ADD
ADD = {<x, y> | x, y >0 are binary integers where x + y is an integer
whose binary repre
representation
sentation is palindrome}. Show that PAL-ADD
PAL ϵ LSPACE.
Solution:
Let PAL
PAL-ADD
ADD = {x,y>0, are binary integers whose x+y is an integer is a Palindrome}.
Show PAL
PAL-ADD ε LSPACE ?
M1 = “On input string w:
1. Scan across the tape and look for 0s and 1s
2. Count number of 0s separately
3. Count number of 1s separately
4. Compare
ompare both the counters if both are equal accept, otherwise reject the machine
countsthe number of 0s and, separately, the number of 1s in binary on the work tape.
The only space required is tthat
hat used to record the two counters. In binary, eachcounter
uses only logarithmic space and hence the algorithm runs in O(log n)space.
Therefore, A є L.

Q.#. 34. A subset of nodes of a graph is a dominating set if every other node of G is
adjacent to some node in the subset. Let DOMINATING-SET={<G,
DOMINATING SET={<G, k> | G has a
dominating set with k nodes}. Show that it is NP
NP-Complete
Complete by giving a reduction
from VERTEX
VERTEX-COVER.
Solution:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 12
Q.#. 35. Show that MULT-SAT is NP-complete.
Solution:
In direction to gratify that SAT is NP
NP-complete,
complete, we necessity describe 3-CNF
3 CNF formula.
CNF formula is in conjunctive normal form and if all clause with three literals are
connected with AND ( ) operation then we say it is a 3CNF formula.
Example of 3CNF fo formula.

Ф=
We say that 3CNF formula is satisfiable if at least one literal of every clause is
specified value 1.
As we recognize giving to COROLLARY certain in textbook (7.42) that 3SAT is NP
complete.
Proof: theorem (theorem7.37)
3-SAT
SAT is NP complete.
In directive to proof we have to prove that all languages in NP reduce to 3SAT in
polynomial time. Rendering to this a formula is formed in conjective normal form with
three literals in every clause. In every clause OR operation is between literal and
clause
use are connected in AND operation as example is given above.

So we can relay this theorem to prove that Multi


Multi-SAT problem.
In case of certain problem there are 10 satisfying assignment which are
x1,x2,x3,,x4,….,x10. It mean that if we enhance new variabl
variablee in every clause then
there necessity be Ф =1 in case of MULTI
MULTI-SAT.
SAT.
So we can say that formula is satisfiable even we have add more literal up to 10. As
we know that 33-SAT
SAT is NP complete and MULT-SAT
MULT achieve all 3-SAT assets.

Q.#. 36. Says that 33-SAT is reducible


le in polynomial time if clique is solvable in polynomial
time. So we can transmit it MUT
MUT-SAT
SAT which can be solved in polynomial time.
We can narrate 33-SAT and MULTI-SAT SAT owing to remarkable connection among
these two problems. Mutually problems can be reduced polynomial time.
So we can say MULT_SAT is NP complete as 33-SAT is NP complete.
Solution:
The traditional Nim
Nim-game (aka Marienbad-game)
game) consists of four rows of 1, 3, 5 and 7
matchsticks (or any other objects). Two players take any number of matchsticks from
one row alternately. The one, who takes the last matchstick loses.
The winning strateg
strategy is:
You must always take as many matchsticks as possible so that the “Nim sum” of the
rows remains ZERO.

Q.#. 37. Read the definition of MIN


MIN-FORMULA
FORMULA is problem.
a. Show that MIN-FORMULA ∈ PSPACE
b. Explain why this argument fails to show that MIN-Formula
MIN ∈ coNP:
If ∅  MIN-FORMULA, then ∅ has a smaller equivalent formula. An
NTM can verify that ∅ ∈ MIN - FORMULA by guessing that formula.
Solution:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 13
Q.#. 38. Prove LPATH is NP-Complete
Solution:

Q.#. 39. Consider the following scheduling problem. You are given a list of final exams F1
, .. . , Fk to be scheduled, and a list of students Si, . . . , SI. Each student is taking
some specified subset of these exams. You must schedule these exams into slots so
that no student is required to take two exams in the same slot. The problem is to
determine if such a schedule exists that uses only h slots. Formulate this problem
as a language and show that this language is NP-complete.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 14
Q.#. 40. Consider the following generalized geography game wherein the start node is the
one with the arrow pointing in from nowhere.
Does Player-I have a wining strategy?
Does Player-II?
Give reasons for you answers.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 15
Q.#. 41. Show that for any function f:N R+, where f(n)≥n, the space complexity class
SPACE(f(n)) is the same whether you define the class by using the single tape TM
Model or the two tape read only input model.
Solution:

Q.#. 42. A directed Graph is STRONGLY-CONNECTED of every two nodes are


connected by a directed graph in each direction. Let STRONGLY-CONNECTED
= {<G>|G is strongly connected graph}. Show that STRONGLY-CONNECTED is
NP-Complete.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 16
Q.#. 43. Let G represents an undirected graph. Also let
SPATH={<G,a,b,k>|G contains a simple path of length at most k from a to b}
LPATH={<G,a,b,k>|G contains a simple path of length at most k from a to b}
Show that SPATH in P
Show that LPATH is NP-Complete. You may assume that NP-Completeness
of UHAMPATH, the Hamiltonian path problem for undirected graph.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 17
Q.#. 44. A triangle is in an undirected graph is a 3-clique. Show that Triangle in P
where Triangle={<G>|G Contains a Triangle}
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 18
Q.#. 45. Let CONNECTED={<G>|G is connected undirected graph}. Show that it is in P.
Solution:

Q.#. 46. Show that directed hymoltonian cycle is NP-Complete.


Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 19
Q.#. 47. IET={Add{x,y,z) | x,y,z > 0 are binary integers and x+y=z}.
Show that ADD is in L.
Solution:

Q.#. 48. Let SET-SPLITTING={(S,C) I S is a finite set and C = {C1, . . ,Ck} is a collection
of subsets of S, for some k >0, such that elements of S can be colored redor blue
so that no Ci has all its elements colored with the same color.} Show that SET-
SPLITTING is NP-complete.
Solution:

Q.#. 49. If F={1,2,3,4] and S={{1,3},{1,2},{2,3,4}}, the {F,S,2}  SCHEDULE, but


{F,S,3} ∈ SCHEDUlE. Show that SCHEDULE is NP-Complete.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 20
Q.#. 50. A coloring of a graph is an assignment of colors to its nodes so that no two
adjacent nodes are assigned the same color.
Let 3COLOR = { (G) I the nodes of G can be colored with three colors such that
no two nodes joined by an edge have the same color}.
Show that 3COLOR is NP-complete. (Hint: Use the following three subgraphs.)
Solution:

Q.#. 51. Let A be the language of properly nested parentheses. For example, ( ( ) ) and ( ( )
( ( ) ) ) ( ) are in A, but )( is not. Show that A in in L.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 21
We know that the class L contains all problems requiring only a fixed number of
counters/pointers to solve them. The language A requires one counter. Initially, the
counter is 0, and, as the head moves to the right along the tape, the counter is
incremented by 1 if the symbol read is “(”, and it is decremented by 1 if the symbol
read is “)”. If the counter ever becomes negative we reject the string (more closing
parentheses then opening ones). If the counter is positive after reading the last symbol
in the string, we reject (more opening parentheses then closing ones). Otherwise, we
accept.

Q.#. 52. Show that EDFA is NL-complete.


Solution:

Q.#. 53. Define ALBA = {(M, w) I M is an LBA that accepts input w}. Show that ALBA is
PSPACE-complete.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 22
Q.#. 54. Define ALBA = {(M, w) I M is an LBA that accepts input w}. Show that ALBA is
PSPACE-complete.
Solution:

Q.#. 55. Show that A is NP-Complete.


Solution:
A language A is called NP-Complete ,
1 if A is NP-Hard
2 And A is in NP.
NP-Hard:- A languages A is NP-Hard, if every language L NP and L≤p P .
If both conditions are satisfied, then the language A is in NP-Complete.

Q.#. 56. Prove that Double SAT is NP-Complete (by reducing from 3 SAT)
Solution:
DOUBLE-SAT is in NP because the following is a polynomial time verifier for
DOUBLE-SAT.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 23
V is verifier
V = On input << Φ >,c>: where c is certificate

 Test whether c contains two different assignments.


 Test whether both of the two assignments satisfy Φ .
 If both satisfied accept, otherwise reject.

We take 3SAT problem as known NP-Complete problem and reduce to the DSAT.
3SATcontains Φ and Φ is in CNF form and Φ is satisfiable.
We show that 3SAT ≤p DSAT. Given a formula Φ and define f(<Φ >) = Φ V Φ’,
where Φ’ is a formula with every literal in Φ complemented(e.g. negation of x is a
complement of x). if Φ is satisfiable, then Φ V Φ’ has at least two satisfying
assignments, one is the same as one satisfying assignment for Φ, and another one is by
complementing each variable’s assignment in the previous satisfying assignment. In
the reverse direction, if Φ V Φ’ has at least two satisfying assignments, then either Φ
or Φ’ is satisfied. If Φ is satisfied then we are done. If Φ’ is satisfied then we can
complement the assignment of every variable to get a satisfying assignment for Φ and
the time taken by this reduction is polynomial to the number of variables in Φ.

Q.#. 57. Let DOUBLE-SAT={ <φ>| φ has atleast two satisfying assignments }. Show that
DOUBLE-SAT is NP-Complete
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 24
Q.#. 58. Graphs G and H are called isomorphic if the nodes of G may be reordered so that
it is identical to H. Let ISO = {<G, H> | G and H are isomorphic graphs}. Show
that ISO ∈NP
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 25
Q.#. 59. The game of Nim is played with a collection of piles of sticks. In one move a
player may remove any nonzero number of sticks from a single pile. The
players alternately take turns making moves. The player who removes the very
last stick loses. Say that we have a game position in Nim with k piles
containing s1, ..., sk sticks. Call the position balanced if, when each of the
numbers si is written in binary and the binary numbers are written as rows of a
matrix aligned at the low order bits, each column of bits contains an even
number of 1s. Prove the following two facts. Starting in an unbalanced
position, a single move exists that changes the position into a balanced one.
Starting in a balanced position, every single move changes the position into
an unbalanced one.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 26
Q.#. 60. Show that directed hamiltonian cycle is NP-Complete
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 27
Q.#. 61. Let NEAR TAUT; given Boolean expression E all the variables are made f, is
there some other truth assignment besides all f that make E true. Show that the
NEAR TAUT is NPNP-Complete
Complete by reducing SAT to it.
Solution:

Q.#. 62. Prove Multi SAT is NP


NP-Complete
Solution:

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 28
Q.#. 63. Let A = {<M, x, # t >|NTM, M accepts input x within t steps on at least one
branch}. Show that A is NP-Complete. Here A= U
Solution:

Q.#. 64. Prove cycle- length problem is NL-Complete.


Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 29
Q.#. 65. For a CNF
CNF-formula - with m variables and c clauses, show that you can
construction polynomial time an NFA with O(cm) states that accepts all non
non-
satisfying assignments, represented as Boolean strings of length m. Conclude that
P = NP implies that NFAs cannot b bee minimized in polynomial time or Conclude
that NFAs cannot be minimized in polynomial time unless=NP.
Solution:

Q.#. 66. Prove that EQNFA{....} prove that EQNFA is PSPACE


PSPACE-complete if P=NP
Solution:
Because of the potential change in input size when the NFA is converted to a DFA, the
NL algorithm for EQDFA uses NPSPACE in terms of the original input. So EQNFA is
not shown to be in NL by this argument and there is no contradiction with its being
PSPACE complete.

Q.#. 67. 3CNF NP complete.


Solution:
As 3SAT is NPNP-complete,
complete, it might be convenient for us if we are able to reduce 3SAT3SA
to CNF3. So, we need to make each variables of 3SAT appear only as most as thrice in
the formula. So, we need to introduce new variables which will replace the variables
appearing more than three times. Let us do this this way. If a variable appears more
then three times, let us introduce a range of variables (x1, x2, ...., xn), xi for each i -th
occurrence. Now to make this new version work, we need to add the translation
clauses to the formula. Here is the clause,
(x1 -> x2) ^ (x2 -> x1) ^ ..... ^ (xn-1 -> xn) (xn -> x1)
We can write any xi xi->
> xj as not(xi) OR xj. So, we convert the translation clause as
follows.
(-x1 OR x2) ^ (x2 -> x1) ^ ..... ^ (xn-1 -> xn) (xn -> x1)
When we add the formula to our original formula with all variables, appearing more
than
an 3 times, replaced with the new variables, we get the formula in CNF3 form. The
new formula has exactly the same satisfiable condition as 3SAT. As we have reduced
3SAT to a generic CNF3, it is a representative reduction over the whole set.

CS701-Final
Final Term Solved
Prepared By: Aamir Shahzad - 0300-681-9942 Page 30
But as the original formula, i.e. 3SAT, is NP-complete, CNF3 is also NP-complete.

Q.#. 68. min_formula PSPACE


Solution:
MIN-FORMULA = { <F> : F is a propositional formula that is *not* equivalent to
any shorter propositional formula }
Algorithm: On input <F>:
1. Iterate over all strings s such that |s| < |<F>|, in lexicographic order, and for
each one...
2. Reject if s = <F'> for some propositional formula F' such that F and F' share the
same variables and F and F' are equivalent
-- this can be checked by evaluating both F and F' over all possible assignments to
their variables.
1. Accept if all strings of length less than |<F>| have been checked and none of
them encode a formula equivalent to F.
Correctness: This rejects if F is equivalent to some shorter propositional formula
(because it will find such a formula) and it accepts otherwise, i.e., it decides MIN-
FORMULA.
Space: This requires linear space to store the current string s being examined, linear
space to store assignments to the variables of F and F', and linear space to evaluate F
and F'. All of this space can be reused from one string s to the next, so the total space
usage is linear.

Solution:

Solution:

Solution:

Solution:

Solution:

Current Papers
Q.#. 69. Let ADD = {<x, y, z> | x, y, z >0 are binary integers and x + y =z}.
Show that ADD ϵ LSPACE.
Solution:

Q.#. 70. Consider following instance of PCP. Is it possible to find a match? If yes then give
the dominos arrangements. If NO then prove. (5)
Solution:
Q.#. 71. Show that some true statement in TH(N, +, X) are not provable. (10)
Solution:

Q.#. 72. Thsese nmbrs are relatively prime or not 1274 and 10505.(5)
Solution:

Q.#. 73. Let A be a set of 123 and b set of 7654321. Table main values theen aur pocha
tha k g (n ) correspondence hy ya nai
Solution:

Q.#. 74. Let A be a regular expression. Show that A is decidable.


Solution:

Q.#. 75. Scpc top and bottom strings are of same length. Show that scpc is decidable.
Solution:

Q.#. 76. These Numbers are relatively prime or not 1274 and 10505.
Solution:

Q.#. 77. Let X be the set {1, 2, 3, 4, 5} and Y be the set {6, 7, 8, 9, 10}. We describe the
functions f: X - Y and g: X Y in the following tables. g is one to one then describe.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 31
Solution:

Q.#. 78. A={<R>|R is a regular expression describing a language containing at least one
string w that has 111 as substring(i.e.w=x111y for some x,y } show A is decidable.
Solution:

Q.#. 79. Let A be a set of 123 and B set of 7654321. Table main values theen aur pocha tha
k f (n ) onto btana tha hy ya nhi..
Solution:

Q.#. 80. If A<B and B is regular language show A is true regular


Solution:

Q.#. 81. L all={<M> l M is TM with input (sigma) and L(M)= (sigma)*}


Solution:

Q.#. 82. Show that A < TB , B < T C, A < TC (10)


Solution:

Q.#. 83. Let x be the set {1,2,3,4,5} and y be the set {6,7,8,9,10}we describe the functions
f:xy and g:xy in the following table
Solution:
n F(n) n G(n)
1 6 1 10
2 7 2 9
3 6 3 8
4 7 4 7
5 6 5 6
Is f onto?justify
Solution:

Q.#. 84. Let L={<M>!M is a tm and if we start m with a blank input tape then it will
finally writes some non blank symbol on its tape} is L decidable?
Solution:

Q.#. 85. Let LAll={<M>!M is a tm with input alphabet sigma and L(M) = sigma* }prove
that LAll is not turing recognizeable.
Solution:

Q.#. 86. Show that if A is turing reducible to be ,b is turing reducible to c, c is turing


reducible to A.
Solution:

Q.#. 87. Useless state in a turing machine is one that is never entered on any input string
consider the problem of determining whether a turing machine has any useless
states and formulate this problem as a language and show that it is undecidable.
Solution:

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 32
Final Paper 31-01-2015
1. EMPTINESS problem for LBA is decidable ?
 TRUE
 FALSE
2. A property that holds for almost all strings also hold incompressible strings ?
 TRUE
 FALSE
3. For a TM M and string w Let CH M ,w ={x|x is an acceptable computation History M on
w}. Then CH M ,w is decidable ?
 1. TRUE
 2. FALSE
4. A string x is b-compressible if K(x)>|x|- b ?
 1. TRUE
 2. FALSE
5. If L is decidable Language LR will also be decidable ? Note( LR demotes reverse of
Language)
 1. TRUE
 2. FALSE
6. A correspondence or one-to-one correspondence is a function that both one-to-one and
onto ?
 1. TRUE
 2. FALSE
2 2
7. Time ( n ) contains Time (n log n tha ya n log )
 1. TRUE
 2. FALSE
8. If A reduces to B, It is not necessary that compliment of A reduces to compliment of B ?
uaqi uq j ac ?
 Q.9 yields
 1.  (q i , Blank ) = (q j, c, L ) Correct Option rest of three are not in mind.

9. Let L  {a i b j c k :i  j k i, j, k  0} Which String belongs to L?


 1. aabb
 2. aabbcccc
 3. aaabbccc
 4. aabbbccc

10. Consider following instance of Post Correspondence Problem (PCP). Is it possible to find
a match for PCP instance given below? If YES, then give the dominos arrangement
which will result in a match. If NO, then prove. 05 Marks
{[ 001], [ 10 ], [ 01 ] }
10 00 011
11. Consider the sentence, yx[ R1 ( x, x, y )] 10 Marks
Let assign "PLUS" TO R, where "PLUS" (a,b,c) is True whenever a+b=c, If "Universe"
is R(Real Number). Is this sentence True ? Justify your answer?
12. Prove PCP decidable for unary alphabet   {1} 10 Marks
13. Prove that A TM  m ETM ? 10 Marks
14. Show that Show that the collection of decidable languages is closed under the operation
of concatenation. 10 Marks
15. Let t(n) be a function, where t ( n)  n . Then every t(n) time nondeterministic single tape
TM has an equivalent 20(t ( n )) time deterministic single tape TM.

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 33
CS703 ADVANCE OPERATING SYSTEM
28-08-2015 at 2:00Pm

1. In demand paging pages are only brought into _____when they only referenced only the
code data that is needed by process needs to be loaded.
a) Cache
b) Page Table
c) Segment Table
d) Main Memory

2. Each Process has a separate pool of pages a page fault in one process can only replace
one of this process.
a) Pages
b) Segments
c) ID
d) Frames

3. _______ is when the system spends most of its time servicing page faults little time doing
useful work done.
a) Spoofing
b) Faculty
c) Thrashing
d) Throughput

4. While conservatively moving a file there is a rule reset old pointer to _____before a new
pointer has been set.
a) Attribute
b) Value
c) Node
d) Object

5. In virtual file system _____ object represents a specific directory entry.


a) Superblock
b) Inode
c) File
d) Dentry

6. Hardware layer of I/O system performs operation.


a) I/O
b) Naming
c) Setup Registers
d) Spoofing

7. _________ timers may be dynamically created and destroyed.


a) I/O
b) Dynamic
c) State
d) Memory

8. In loadable kernel module sections of kernel code can be compiled loaded and unloaded
independent of the rest of _______
a) Kernel
b) Code
c) Compilation
d) Memory

9. __modeules allow a linux system to be set up with a standard minimal kernel without
any extra device driver built in
a) Code
b) Kernel
c) Memory
d) Compilation

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 34
10. IN _________ security mechanism system know who the user & user enters a name and
password or other info.
a) Access control
b) Biometric
c) Security
d) Physical security

11. File management on any secondary storage devices needs a mechanism which depends
upon how an OS system handles if you are required to identify & explain the method of
file management that can be applied on floppy disk using MS-DOS? (5 marks)
12. What are five major activities of an operating system in regard to file management?(5
marks)
13. When a program enters into an infinite loop and never returns control back to CPU.
Explain how timer interrupt help to terminate this condition ? This result in CPU never
gets control back. How does timer interrupt the OS?(5 marks)
14. Briefly explain major security issues.(10 marks)
15. How authentication can achieve by biometric?(10marks)
16. What are difficulties with working set? Describe in detail & also provide
examples?(10marks)
17. Why Rotational latency is not considered in disk scheduling? How FCFS, SSTF, SCAN
and C-SCAN are modified for rotational latency optimization ?( 10 Marks)

CS701-Final Term Solved


Prepared By: Aamir Shahzad - 0300-681-9942 Page 35

Das könnte Ihnen auch gefallen