SlideShare a Scribd company logo
1 of 7
Download to read offline
UNIVERSITY TEKNOLOGI MALAYSIA
MIDTERM TEST
SEMESTER I 2013/2014
CODE OF SUBJECT
: SCSJ3203
NAME OF SUBJECT
: Theory of Computer Science
YEAR/COURSE
: 3SCSJ, 3SCSR, 3SCSV, 3SCSI, 3SCSD, 3SCSB
TIME
: 10.15 am – 12.15 pm (2 hours)
DATE
: 31 October 2013
VANUE
: BK1 – BK6 (N28)
_____________________________________________________________________________________
INSTRUCTION TO THE STUDENTS
PART A
PART B

: 10 TRUE/FALSE QUESTIONS (10 MARKS)
: 10 SUBJECTIVE QUESTIONS (90 MARKS)

THIS PAPER CONSIST OF 2 PARTS. ANSWER ALL QUESTION IN THE SPACE PROVIDED IN THIS QUESTION
PAPER. THE MARKS FOR EACH QUESTION IS AS INDICATED.

ANSWER ALL QUESTION IN THE SPACES ALLOCATED IN THIS BOOKLET.

Name
IC (or matric) number
Name of lecturer
Subject code and section

SCJ3203 Section 01 / 02 / 03 / 04 / 05 / 06
(pls. circle tour section)

This examination book consists of 6 printed pages excluding this page.
Part A – True and false questions

[10 marks]

_____________________________________________________________________________________
There are 10 questions in this section. For each question, state whether it is TRUE or FALSE and write your
answer in the space given. Each question carries 1 marks.

Answer
1.

λ is always subset of every set.

___________

2.

L1L2 = {xy | x ϵ L1 and y ϵ L2}, if L1 = {a, aa} and L2 = {λ, b, ab},
thus L1L2 = {a, b, aa, ab, aab, aaab}.

___________

3.

A regular expression for set of strings over {a, b} containing
two or more b’s is (a + b)*b(a + b)*b(a + b).

___________

4.

Two example expressions that represent the same set of
strings are (0 + 1 + λ)* and (0 + 1)*.

___________

5.

R = a* + b* generates any string with the combination of a’s
and b’s.

___________

6.

The following grammar; S → aS; S → baSS; S → b over
alphabet {a, b} is regular.

___________

7.

abab is generated by S → aX; X → bX; X → a;

___________

8.

A regular grammar does not generate the empty string.

___________

9.

A regular grammar is also a context-free grammar.

___________

10.

The following grammar; S → aX; X → bY; Y → aS; X → b;
generates the language of (aba)*ab.

___________

1
PART B – SUBJECTIVE QUESTIONS
[90 MARKS]
_____________________________________________________________________________________
This part consists of 10 structured questions. Answer all questions in the space provided. The marks for
each part of the question is as indicated.

1. Consider the language S* where S = {a, ab, ba}. Write three strings that are IN and NOT IN the
language in Table 1.
[6 marks]
Table 1

IN the language

NOT IN the language

2. For the two regular expression:
[4 marks]
r1 = a* + b*
r2 = ab* + ba* + b*a + (a*b)*
a. Find two strings corresponding to r2 but not r1.
b. Find two strings corresponding to both r1 and r2.

_____________________
_____________________

3. Find a regular expression corresponding to the following languages.
a. The language of all strings over the alphabet {a, b} that do not end with ba.
[4 marks]
___________________________________________________________________
b. The language of all strings over the alphabet {a, b} that contain no more than one
occurrence of the string bb.
[4 marks]
___________________________________________________________________
c. The language of strings of even lengths over the alphabet of {a, b}.
[4 marks]
___________________________________________________________________

2
4. Describe as simply as possible in English the language corresponding to the following regular
expressions
a. (b + aa)(a + b)*

[3 marks]

_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
b. a*b(a*ba*b)*a*

[3 marks]

_________________________________________________________________
_________________________________________________________________
_________________________________________________________________
5. construct a context-free grammar that generate the following language
a. {anbm | n<m}
[4 marks]
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

b. {a3nb2n | n ≥ 0}
[4 marks]
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

c. {a3n+1b2n | n ≥ 0}
[4 marks]
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

3
6. For each of the following context-free grammar, write the equivalent regular grammar and regular
expression.
[18 marks]
Context free grammar

Regular grammar

Regular expression

S → aBa
B → bB | λ
S → abS | λ
S → Aa
A → aA | bA | λ

7. Design a CFG rules for the following regular expression.

[4 marks]

(a + b)*aa(a + b)*
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

8. Consider the following grammar
G1:

S → aSa | aBa
B → bB | b

a. Use the set notations to define the language generated by the grammar, L(G1).
[3 marks]
___________________________________________________________________________

b. What is the shortest string that can be produced from the grammar?
[1 mark]
___________________________________________________________________________

c. Write another possible string that can be generated from the language.
[1 mark]
___________________________________________________________________________

4
9. Let G2 be the grammar
S → AB
A → aA | λ
B → bB | λ
a. Give a leftmost derivation of the string aabbb.
[3 marks]
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

b. Give the rightmost derivation of string abbbb.
[3 marks]
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

c. Build the derivation tree for the derivations in parts (a) and (b).

[4 marks]

5
d. Give a regular expression for L(G2). _________________________

[3 marks]

10. The following is a CFG to generate a language.
S → A1B
A → 0A | λ
B → 0B | 1B | λ
a. Give leftmost derivations of the following string.

[6 marks]

i. 00101
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

ii. 10001
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

b. What is the regular expression for this CFG.

[4 marks]

___________________________________________________________________________

-END OF QUESTIONS6

More Related Content

What's hot

Chapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.pptChapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.ppt
FamiDan
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
Eelco Visser
 
Automatic Essay Grading_Final
Automatic Essay Grading_FinalAutomatic Essay Grading_Final
Automatic Essay Grading_Final
Sahilc2200
 

What's hot (20)

Pumping lemma for cfl
Pumping lemma for cflPumping lemma for cfl
Pumping lemma for cfl
 
Compiler1
Compiler1Compiler1
Compiler1
 
Peephole optimization
Peephole optimization Peephole optimization
Peephole optimization
 
Chapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.pptChapter 3 -Syntax Analyzer.ppt
Chapter 3 -Syntax Analyzer.ppt
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Lua Programming Language.pptx
Lua Programming Language.pptxLua Programming Language.pptx
Lua Programming Language.pptx
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Lecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdfLecture Notes-Are Natural Languages Regular.pdf
Lecture Notes-Are Natural Languages Regular.pdf
 
Turing machine
Turing machineTuring machine
Turing machine
 
Computer language
Computer languageComputer language
Computer language
 
Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation november december 2015  be cse anna university q...Cs6503 theory of computation november december 2015  be cse anna university q...
Cs6503 theory of computation november december 2015 be cse anna university q...
 
Automatic Essay Grading_Final
Automatic Essay Grading_FinalAutomatic Essay Grading_Final
Automatic Essay Grading_Final
 
Finite automata
Finite automataFinite automata
Finite automata
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Programming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwaresProgramming languages,compiler,interpreter,softwares
Programming languages,compiler,interpreter,softwares
 

Similar to SCSJ3203 - Theory Science Computer - Midterm Paper

0580 w13 qp_21
0580 w13 qp_210580 w13 qp_21
0580 w13 qp_21
King Ali
 
Mid module 1 test review
Mid module 1 test reviewMid module 1 test review
Mid module 1 test review
mlabuski
 
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docxMath 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
andreecapon
 
Fall Semester Review Part A Alg 1 B
Fall Semester Review Part A Alg 1 BFall Semester Review Part A Alg 1 B
Fall Semester Review Part A Alg 1 B
Sedona Red Rock HS
 
G6 m5-b-lesson 8-note sheet
G6 m5-b-lesson 8-note sheetG6 m5-b-lesson 8-note sheet
G6 m5-b-lesson 8-note sheet
mlabuski
 
Mathematics Mid Year Form 4 Paper 2 2010
Mathematics Mid Year Form 4 Paper 2 2010Mathematics Mid Year Form 4 Paper 2 2010
Mathematics Mid Year Form 4 Paper 2 2010
sue sha
 

Similar to SCSJ3203 - Theory Science Computer - Midterm Paper (20)

Math practice
Math practiceMath practice
Math practice
 
Mama march 13
Mama march 13Mama march 13
Mama march 13
 
0580_w14_qp_21
0580_w14_qp_210580_w14_qp_21
0580_w14_qp_21
 
0580_w13_qp_23
0580_w13_qp_230580_w13_qp_23
0580_w13_qp_23
 
apostia
apostia apostia
apostia
 
0580 w13 qp_21
0580 w13 qp_210580 w13 qp_21
0580 w13 qp_21
 
0580_w13_qp_21
0580_w13_qp_210580_w13_qp_21
0580_w13_qp_21
 
Mid module 1 test review
Mid module 1 test reviewMid module 1 test review
Mid module 1 test review
 
Activity 3 (answer key)
Activity 3 (answer key)Activity 3 (answer key)
Activity 3 (answer key)
 
ใบงานที่ 5
ใบงานที่ 5 ใบงานที่ 5
ใบงานที่ 5
 
Pp1 sunieta
Pp1 sunietaPp1 sunieta
Pp1 sunieta
 
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docxMath 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
Math 107 Final ExaminationSpring, 20131Math 107 College Algebr.docx
 
Fall Semester Review Part A Alg 1 B
Fall Semester Review Part A Alg 1 BFall Semester Review Part A Alg 1 B
Fall Semester Review Part A Alg 1 B
 
Modul sept okt tahun 3
Modul sept okt tahun 3Modul sept okt tahun 3
Modul sept okt tahun 3
 
Final exam year 1 paper 2 revision
Final exam year 1 paper 2 revisionFinal exam year 1 paper 2 revision
Final exam year 1 paper 2 revision
 
Final exam year 1 paper 2 revision
Final exam year 1 paper 2 revisionFinal exam year 1 paper 2 revision
Final exam year 1 paper 2 revision
 
11-Plus-Maths.pdf
11-Plus-Maths.pdf11-Plus-Maths.pdf
11-Plus-Maths.pdf
 
G6 m5-b-lesson 8-note sheet
G6 m5-b-lesson 8-note sheetG6 m5-b-lesson 8-note sheet
G6 m5-b-lesson 8-note sheet
 
Mathematics Mid Year Form 4 Paper 2 2010
Mathematics Mid Year Form 4 Paper 2 2010Mathematics Mid Year Form 4 Paper 2 2010
Mathematics Mid Year Form 4 Paper 2 2010
 
Bahasa Inggeris Tahun 1 Kertas 1 Ogos 2016
Bahasa Inggeris Tahun 1 Kertas 1 Ogos 2016Bahasa Inggeris Tahun 1 Kertas 1 Ogos 2016
Bahasa Inggeris Tahun 1 Kertas 1 Ogos 2016
 

More from Abdul Khaliq

ULAB3122 / UHS3022 - Final Exam Paper
ULAB3122 / UHS3022 - Final Exam PaperULAB3122 / UHS3022 - Final Exam Paper
ULAB3122 / UHS3022 - Final Exam Paper
Abdul Khaliq
 
Soalan orienteering
Soalan orienteeringSoalan orienteering
Soalan orienteering
Abdul Khaliq
 
orienteering - saling pandang
orienteering - saling pandangorienteering - saling pandang
orienteering - saling pandang
Abdul Khaliq
 
orienteering - cerun
orienteering - cerunorienteering - cerun
orienteering - cerun
Abdul Khaliq
 
orenteering - mengenal cerun
orenteering - mengenal cerunorenteering - mengenal cerun
orenteering - mengenal cerun
Abdul Khaliq
 
Computational mathematic
Computational mathematicComputational mathematic
Computational mathematic
Abdul Khaliq
 

More from Abdul Khaliq (20)

UHB 3022 / ULAB 3122 - Final Exam Paper
 UHB 3022 / ULAB 3122 - Final Exam Paper UHB 3022 / ULAB 3122 - Final Exam Paper
UHB 3022 / ULAB 3122 - Final Exam Paper
 
SCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTMSCSJ3553 - Artificial Intelligence Final Exam paper - UTM
SCSJ3553 - Artificial Intelligence Final Exam paper - UTM
 
ULAB3122 / UHS3022 - Final Exam Paper
ULAB3122 / UHS3022 - Final Exam PaperULAB3122 / UHS3022 - Final Exam Paper
ULAB3122 / UHS3022 - Final Exam Paper
 
ULAB3122 / UHS3022 - Final Exam Paper (2009)
ULAB3122 / UHS3022 - Final Exam Paper (2009)ULAB3122 / UHS3022 - Final Exam Paper (2009)
ULAB3122 / UHS3022 - Final Exam Paper (2009)
 
UHB2422 / ULAB2112 - Final exam paper with answer sample
UHB2422 / ULAB2112 - Final exam paper with answer sampleUHB2422 / ULAB2112 - Final exam paper with answer sample
UHB2422 / ULAB2112 - Final exam paper with answer sample
 
UHB2422 / ULAB2112 - Final exam paper
UHB2422 / ULAB2112 - Final exam paperUHB2422 / ULAB2112 - Final exam paper
UHB2422 / ULAB2112 - Final exam paper
 
Soalan orienteering
Soalan orienteeringSoalan orienteering
Soalan orienteering
 
Orienteering - titik utara
Orienteering - titik utaraOrienteering - titik utara
Orienteering - titik utara
 
orienteering - saling pandang
orienteering - saling pandangorienteering - saling pandang
orienteering - saling pandang
 
orienteering - cerun
orienteering - cerunorienteering - cerun
orienteering - cerun
 
orenteering - mengenal cerun
orenteering - mengenal cerunorenteering - mengenal cerun
orenteering - mengenal cerun
 
Orienteering - kompas prismatik
Orienteering - kompas prismatikOrienteering - kompas prismatik
Orienteering - kompas prismatik
 
UICI 2022 - Bab 04 teknologi dalam islam (nota)
UICI 2022 - Bab 04 teknologi dalam islam (nota)UICI 2022 - Bab 04 teknologi dalam islam (nota)
UICI 2022 - Bab 04 teknologi dalam islam (nota)
 
UICI 2022 - Bab 03 sains dan islam (nota)
UICI 2022 - Bab 03 sains dan islam (nota)UICI 2022 - Bab 03 sains dan islam (nota)
UICI 2022 - Bab 03 sains dan islam (nota)
 
UICI 2022 - Bab 02 perpindahan ilmu (nota)
UICI 2022 - Bab 02 perpindahan ilmu (nota)UICI 2022 - Bab 02 perpindahan ilmu (nota)
UICI 2022 - Bab 02 perpindahan ilmu (nota)
 
UICI 2022 -Bab 01 manusia dan ilmu (nota)
UICI 2022 -Bab 01 manusia dan ilmu (nota)UICI 2022 -Bab 01 manusia dan ilmu (nota)
UICI 2022 -Bab 01 manusia dan ilmu (nota)
 
Computational mathematic
Computational mathematicComputational mathematic
Computational mathematic
 
A intro uici 2022 sains teknologi dan manusia
A intro uici 2022   sains teknologi dan manusiaA intro uici 2022   sains teknologi dan manusia
A intro uici 2022 sains teknologi dan manusia
 
UICI 2022 - sains dan islam
UICI 2022 - sains dan islamUICI 2022 - sains dan islam
UICI 2022 - sains dan islam
 
UICI 2022 - Perpindahan ilmu
UICI 2022 - Perpindahan ilmuUICI 2022 - Perpindahan ilmu
UICI 2022 - Perpindahan ilmu
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

SCSJ3203 - Theory Science Computer - Midterm Paper

  • 1. UNIVERSITY TEKNOLOGI MALAYSIA MIDTERM TEST SEMESTER I 2013/2014 CODE OF SUBJECT : SCSJ3203 NAME OF SUBJECT : Theory of Computer Science YEAR/COURSE : 3SCSJ, 3SCSR, 3SCSV, 3SCSI, 3SCSD, 3SCSB TIME : 10.15 am – 12.15 pm (2 hours) DATE : 31 October 2013 VANUE : BK1 – BK6 (N28) _____________________________________________________________________________________ INSTRUCTION TO THE STUDENTS PART A PART B : 10 TRUE/FALSE QUESTIONS (10 MARKS) : 10 SUBJECTIVE QUESTIONS (90 MARKS) THIS PAPER CONSIST OF 2 PARTS. ANSWER ALL QUESTION IN THE SPACE PROVIDED IN THIS QUESTION PAPER. THE MARKS FOR EACH QUESTION IS AS INDICATED. ANSWER ALL QUESTION IN THE SPACES ALLOCATED IN THIS BOOKLET. Name IC (or matric) number Name of lecturer Subject code and section SCJ3203 Section 01 / 02 / 03 / 04 / 05 / 06 (pls. circle tour section) This examination book consists of 6 printed pages excluding this page.
  • 2. Part A – True and false questions [10 marks] _____________________________________________________________________________________ There are 10 questions in this section. For each question, state whether it is TRUE or FALSE and write your answer in the space given. Each question carries 1 marks. Answer 1. λ is always subset of every set. ___________ 2. L1L2 = {xy | x ϵ L1 and y ϵ L2}, if L1 = {a, aa} and L2 = {λ, b, ab}, thus L1L2 = {a, b, aa, ab, aab, aaab}. ___________ 3. A regular expression for set of strings over {a, b} containing two or more b’s is (a + b)*b(a + b)*b(a + b). ___________ 4. Two example expressions that represent the same set of strings are (0 + 1 + λ)* and (0 + 1)*. ___________ 5. R = a* + b* generates any string with the combination of a’s and b’s. ___________ 6. The following grammar; S → aS; S → baSS; S → b over alphabet {a, b} is regular. ___________ 7. abab is generated by S → aX; X → bX; X → a; ___________ 8. A regular grammar does not generate the empty string. ___________ 9. A regular grammar is also a context-free grammar. ___________ 10. The following grammar; S → aX; X → bY; Y → aS; X → b; generates the language of (aba)*ab. ___________ 1
  • 3. PART B – SUBJECTIVE QUESTIONS [90 MARKS] _____________________________________________________________________________________ This part consists of 10 structured questions. Answer all questions in the space provided. The marks for each part of the question is as indicated. 1. Consider the language S* where S = {a, ab, ba}. Write three strings that are IN and NOT IN the language in Table 1. [6 marks] Table 1 IN the language NOT IN the language 2. For the two regular expression: [4 marks] r1 = a* + b* r2 = ab* + ba* + b*a + (a*b)* a. Find two strings corresponding to r2 but not r1. b. Find two strings corresponding to both r1 and r2. _____________________ _____________________ 3. Find a regular expression corresponding to the following languages. a. The language of all strings over the alphabet {a, b} that do not end with ba. [4 marks] ___________________________________________________________________ b. The language of all strings over the alphabet {a, b} that contain no more than one occurrence of the string bb. [4 marks] ___________________________________________________________________ c. The language of strings of even lengths over the alphabet of {a, b}. [4 marks] ___________________________________________________________________ 2
  • 4. 4. Describe as simply as possible in English the language corresponding to the following regular expressions a. (b + aa)(a + b)* [3 marks] _________________________________________________________________ _________________________________________________________________ _________________________________________________________________ b. a*b(a*ba*b)*a* [3 marks] _________________________________________________________________ _________________________________________________________________ _________________________________________________________________ 5. construct a context-free grammar that generate the following language a. {anbm | n<m} [4 marks] ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ b. {a3nb2n | n ≥ 0} [4 marks] ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ c. {a3n+1b2n | n ≥ 0} [4 marks] ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ 3
  • 5. 6. For each of the following context-free grammar, write the equivalent regular grammar and regular expression. [18 marks] Context free grammar Regular grammar Regular expression S → aBa B → bB | λ S → abS | λ S → Aa A → aA | bA | λ 7. Design a CFG rules for the following regular expression. [4 marks] (a + b)*aa(a + b)* ______________________________________________________________________________ ______________________________________________________________________________ ______________________________________________________________________________ 8. Consider the following grammar G1: S → aSa | aBa B → bB | b a. Use the set notations to define the language generated by the grammar, L(G1). [3 marks] ___________________________________________________________________________ b. What is the shortest string that can be produced from the grammar? [1 mark] ___________________________________________________________________________ c. Write another possible string that can be generated from the language. [1 mark] ___________________________________________________________________________ 4
  • 6. 9. Let G2 be the grammar S → AB A → aA | λ B → bB | λ a. Give a leftmost derivation of the string aabbb. [3 marks] ___________________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ b. Give the rightmost derivation of string abbbb. [3 marks] ___________________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ c. Build the derivation tree for the derivations in parts (a) and (b). [4 marks] 5
  • 7. d. Give a regular expression for L(G2). _________________________ [3 marks] 10. The following is a CFG to generate a language. S → A1B A → 0A | λ B → 0B | 1B | λ a. Give leftmost derivations of the following string. [6 marks] i. 00101 ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ii. 10001 ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ ____________________________________________________________________ b. What is the regular expression for this CFG. [4 marks] ___________________________________________________________________________ -END OF QUESTIONS6