CS701 Solution 2
CS701 Solution 2
CS701 Solution 2
Fall 2018
Assignment 1
The purpose of the assignments is to give students hands on practice. It is expected that
students will solve assignments themselves. Following rules will apply during the
evaluation of the assignment.
Cheating from any source will result in zero marks in the assignment.
Any student found cheating in any two of the assignments submitted during the
course will be awarded "F" grade in the course.
No assignment after due date will be accepted.
1
Virtual University of Pakistan
Fall 2018
Answer the following questions in your own words. Plagiarism will be checked for
each question. Marks will be awarded on the basis of answer and plagiarism report.
Solution:
There are six possible cases:
Three cases: both aa’s come in the start, end or middle
And the rest of three cases:
Hence the expression is:
aabbb* + bbb*aa + bb*aabb* + abbb*a + bb*abb*a + + abb*abb*
Solution:
The idea here is that either number of a’s is greater than the number of b’s or the number
of b’s and greater than the number of a’s.
S → TaT | RbR
T → TT | aTb | bTa | a | ɛ
R → RR | aRb | bRa | b | ɛ
Here T generates all strings with at least as many a’s as b’s and S → TaT forces an extra
a. Similarly, R generates all strings with at least as many b’s as a’s and S → RbR forces
an extra b.
2
Virtual University of Pakistan
Fall 2018
Does the Turing machine accept the string abcc? Show the execution of the Turing
machine on the input by giving the sequence of configurations from the start to the
halting configuration.
Solution:
3
Virtual University of Pakistan
Fall 2018
Solution:
We prove that A is countable by giving one-to-one correspondence with the set of natural
numbers N.
{1 2 3 4 5 …….}
↓ ↓ ↓ ↓ ↓
{4 6 8 10 12 …….}