2
Assignments: Theory of Computation (CS-302) for debarred/absent students in Mid-Sem-II Alice is an imaginative girl. She draws multicolour pictures with three colours red, green and blue. Every picture she draws contains single or multiple strips. Each strip contains either a single or multiple trails of colours. For example the following picture denotes a picture containing three strips. The first strip contains three colour trails blue followed by red followed by green in that order from left-to-right. The second strip contains two colour trails blue followed by green whereas the third strip is a single coloured strip of red only. It is also obvious from the given picture that the length of the strips as well as the length of trails of different colours in each strip may vary. The length of trails of each colour in each strip can be considered as multiple of a fixed unit-size (represented by the individual rectangular cells in the picture. Different colour codes can be added to represent colour trails as follows-- r for red, g for green, b for blue. A trail of colour red can be coded as r n for n number of consecutive occurrences of unit-sized cells of colour red (e.g. this is equivalent of saying “a red trail of length n”). Similarly, it applies to other colours. In this problem we assume that whenever a colour strip is described, the names of the colours are specified from left-to-right for a strip. Also, the presence of a colour in a strip indicates a non-zero length. A coloured strip can be represented by concatenating the coded colours present in a strip from left-to-right. A picture can be defined by the union of multiple coded strips. Assignment #1: After finishing the first picture, Alice observes an interesting pattern: The picture contains two multicolour strips. The first strip is composed of colours red followed by green followed by blue. The second strip is composed of colours blue followed by green followed by red. In the first strip (from left-to-right) the length of the red trail is double the length of the green trail. The length of the blue trail is not related to the length of trails of other colours. In the second strip (from left-to-right) the length of the blue trail is half of the size of the green trail. The length of the red trail is not related with the length of trails of other colours. Let us consider L be the language defining the picture drawn by Alice. i) Define L. ii) Construct the grammar representing L. Define the grammar as 4-tuples. iii) Design the PDA accepting L. Define the PDA as 7-tuples. If the PDA cannot be designed, justify the reason. 3+5+6=14

Assignments for Debarred-Absent Students of Mid-Sem-II

Embed Size (px)

DESCRIPTION

knfksnfknskfnknfwknfkwk

Citation preview

Page 1: Assignments for Debarred-Absent Students of Mid-Sem-II

Assignments: Theory of Computation (CS-302) for debarred/absent students in Mid-Sem-II

Alice is an imaginative girl. She draws multicolour pictures with three colours red, green and blue.

Every picture she draws contains single or multiple strips. Each strip contains either a single or

multiple trails of colours.

For example the following picture denotes a picture containing three strips. The first strip

contains three colour trails blue followed by red followed by green in that order from left-to-right.

The second strip contains two colour trails blue followed by green whereas the third strip is a

single coloured strip of red only. It is also obvious from the given picture that the length of the

strips as well as the length of trails of different colours in each strip may vary.

The length of trails of each colour in each strip can be considered as multiple of a fixed unit-size

(represented by the individual rectangular cells in the picture. Different colour codes can be

added to represent colour trails as follows-- r for red, g for green, b for blue. A trail of colour red

can be coded as rn for n number of consecutive occurrences of unit-sized cells of colour red (e.g.

this is equivalent of saying “a red trail of length n”). Similarly, it applies to other colours.

In this problem we assume that whenever a colour strip is described, the names of the colours are

specified from left-to-right for a strip. Also, the presence of a colour in a strip indicates a non-zero

length.

A coloured strip can be represented by concatenating the coded colours present in a strip from

left-to-right. A picture can be defined by the union of multiple coded strips.

Assignment #1: After finishing the first picture, Alice observes an interesting pattern: The

picture contains two multicolour strips.

The first strip is composed of colours red followed by green followed by blue. The second strip is

composed of colours blue followed by green followed by red.

In the first strip (from left-to-right) the length of the red trail is double the length of the green

trail. The length of the blue trail is not related to the length of trails of other colours.

In the second strip (from left-to-right) the length of the blue trail is half of the size of the green

trail. The length of the red trail is not related with the length of trails of other colours.

Let us consider L be the language defining the picture drawn by Alice.

i) Define L.

ii) Construct the grammar representing L. Define the grammar as 4-tuples.

iii) Design the PDA accepting L. Define the PDA as 7-tuples. If the PDA cannot be designed,

justify the reason.

3+5+6=14

Page 2: Assignments for Debarred-Absent Students of Mid-Sem-II

Assignment #2: Alice draws a picture. The picture contains two multicolour strips.

The first strip is composed of four trails of colours -- red followed by green followed by blue

followed by red. The second strip is composed of three trails of colours--- blue followed by green

followed by blue.

In the first strip (from left-to-right) the length of the red trail is equal to the length of the green

trail. The length of the blue trail is equal to the length of the adjacent red trail following it.

In the second strip (from left-to-right) the length of the first blue trail is half of the length of the

last blue trail. The length of green trail is not related to the length of the blue trails.

Let us consider L be the language defining the picture drawn by Alice.

i) Define L.

ii) Construct the grammar representing L. Define the grammar as 4-tuples.

iii) Design the PDA accepting L. Define the PDA as 7-tuples. If the PDA cannot be designed,

justify the reason.

3+5+6=14

Assignment #3: Alice draws a picture. The picture contains two multicolour strips.

The first strip is composed of four trails of colours -- red followed by green followed by blue

followed by red. The second strip is composed of three trails of colours--- blue followed by green

followed by red.

In the first strip (from left-to-right) the length of the green trail is equal to the length of the red

trail plus 1. The length of the last red trail is twice the length of the blue trail.

In the second strip (from left-to-right) the length of the blue trail is half of the length of the red

trail. The length of the green trail is not related with the length of other trails of colours.

Let us consider L be the language defining the picture drawn by Alice.

i) Define L.

ii) Construct the grammar representing L. Define the grammar as 4-tuples.

iii) Design the PDA accepting L. Define the PDA as 7-tuples. If the PDA cannot be designed,

justify the reason.

3+5+6=14