Vous êtes sur la page 1sur 5

COURSE : BCS2113 COMPUTER SCIENCE THEORY

STUDENT NAME : MOHD NAZRI SYAH BIN SANI


STUDENT ID : B01150003
ASSIGNMENT : INDIVIDUAL-1
SUBMISSION DATE : 23RD MAY 2017

ASSIGNMENT TOPIC : -

STUDENT DECLARATION

I declare that this material, which I now submit for assessment, is entirely my own work and has
not been taken from the work of others, save and to the extent that such work has been cited and
acknowledged within the text of my work.

I understand that plagiarism, collusion, and copying are grave and serious offences in the university
and accept the penalties that would be imposed should I engage in plagiarism, collusion or copying.
I have read and understood the Assignment Regulations set out in the assignment documentation.

I have identified and included the source of all facts, ideas, opinions, and viewpoints of others in
the assignment references. Direct quotations from books, journal articles, internet sources, module
text, or any other source whatsoever are acknowledged and the source cited are identified in the
assignment references.

This assignment, or any part of it, has not been previously submitted by me or any other person for
assessment on this or any other course of study

DATE :

MARKS :
COMMENT :
1. Consider the language L = {1n2n : n > 0}. Is the string 122 in L?

Answers:
No. If we take n=2 for the above language, the string should be 1122 because
n should hold the same value for 1 and 2.

2. Let L1 = {anbn : n > 0}. Let L2 = {cn : n > 0}. For each of the following
strings, state whether or not it is an element of L1L2:
a) .
b) aabbcc.
c) abbcc.
d) aabbcccc.

Answers:
a) No.
b) Yes.
c) No.
d) Yes.

3. Let L1 = {peach, apple, cherry} and L2 = {pie, cobbler, }. List the


elements of L1L2.

Answers:
L1L2 = {peach, peach pie, peach cobbler, apple, apple pie, apple cobbler,
cherry, cherry pie, cherry cobbler}

4. a) Let L = {w {a, b}* : |w| 3 0 (|w| mod 3 = 0)}. List the first six elements
of L.
b) Write a regular expressions to describe question a).

Answers:
a) L = {, aaa, aab, aba, abb, baa}
b) ((a b)(a b)(a b))
5. Convert the following regular expression to NFAs using the procedure
given in lecture notes.
a) a(abb)* b
b) (1 01)*0*

Answers:
a)

b)
6. Describe in English, as briefly as possible, the language defined by each
of these regular expressions:
a) (a abb)(a b)*(ba bba)
b) (b bab)*

Answers:
a) Begin with either a or abb, then some as or bs (if any) and end with either
ba or bba.
b) Some bs or babs (if any).

7. For each of the following statements, state whether it is True or False. Prove
your answer.
a) (ab)*a = a(ba)*.
b) (a b)* b (a b)* = a* b (a b)*.
c) (a b)* b (a b)* (a b)* a (a b)* = (a b)*.

Answers:
a) True.
1 = {, , , }
2 = {, , , }

b) True.
1 = {, , , , }
2 = {, , , , }

c) False.
1 = {, , , , }
2 = {, , , , , }

8. Discuss the uses of regular expression.

Answers:
Regular expressions are used to test pattern within a string. An input string
can be test to see if it have a telephone number pattern or a credit card
number pattern. In addition, regular expressions are also used to replace text.
Regular expressions can be used to identify a specific text in a document and
delete or replace it with other text.
9. Convert the following finite automata to regular expressions. You need
to show your steps. Describe in English, as briefly as possible, the
language defined by each of these finite automata.
a)

b)

Answers:
a) a*ba*(ba*ba*)*

Begin with some as (if any), followed by b, then some as (if any), and end
with a repetition of b, some as (if any), b and some as (if any).

b) ((a+b)a*b(ba*b)*)*

A repetition that begin with either a or b, followed by some as (if any),


followed with b and end with another repetition of b, some as (if any) and
followed by b.

Vous aimerez peut-être aussi