Beruflich Dokumente
Kultur Dokumente
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.
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).
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.
“On input w
Rum M1 and M2 alternatively on w step by step. If either accept, accept. If
both halt and reject, then reject”
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
Then S is a decider for ATM, which is a contradiction to the fact that ATM is
undecidable.
1. On input x
2. Compute y = f(x)
3. Run M on y
4. If M accepts, accept.
5. If M rejects, reject.
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.#. 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
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.
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.
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,
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.
” ”: 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.
01 10 001
[ ] ,[ ],[ ]
011 00 10
C A B
01 10 01
[ ] ,[ ],[ ]
011 00 011
C A B
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
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
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.#. 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.#. 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.
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:
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.#. 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:
Q.#. 53. Define ALBA = {(M, w) I M is an LBA that accepts input w}. Show that ALBA is
PSPACE-complete.
Solution:
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.
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
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:
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.
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.#. 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.
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.#. 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:xy and g:xy 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.#. 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:
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, yx[ 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.
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
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
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)