• Tidak ada hasil yang ditemukan

Computation Theory Course, 6803415-3 Homework Two

N/A
N/A
Protected

Academic year: 2024

Membagikan "Computation Theory Course, 6803415-3 Homework Two"

Copied!
3
0
0

Teks penuh

(1)

1 Kingdom of Saudi Arabia

Ministry of Education Umm AlQura University

Adam University College, female branch Computer Science Department

ุฉูŠุฏูˆุนุณู„ุง ุฉูŠุจุฑุนู„ุง ุฉูƒู„ู…ู…ู„ุง ู…ูŠู„ุนุชู„ุง ุฉุฑุงุฒูˆ ุฉุนู…ุงุฌ ู‰ุฑู‚ู„ุง ู…ุฃ ุชุงุจู„ุงุทู„ุง ุฑุทุด ุŒู…ุถุฃุจ ุฉูŠุนู…ุงุฌู„ุง ุฉูŠู„ูƒู„ุง

ูŠู„ู„ุขุง ุจุณุงุญู„ุง ู…ูˆู„ุน ู…ุณู‚

First Semester of 2017-2018 Academic Year

Computation Theory Course, 6803415-3 Homework Two

Ch2

Solutions

Question One: 1 Mark

The following is a CFG (Context-Free-Grammar):

๐‘ฌ โ†’ ๐‘ฌ + ๐‘ป | ๐‘ป ๐‘ป โ†’ ๐‘ป ร— ๐‘ญ | ๐‘ญ ๐‘ญ โ†’ (๐‘ฌ) | ๐’‚ Give parase trees and derivations for each string.

a.a b.a+a+a

The Answer of Question One:

a.

Parse Tree:

E

T

F

a Derivations:

๐ธ โŸน ๐‘‡ โŸน ๐น โŸน ๐‘Ž

(2)

2 b.

Parse Tree:

E

E T

E T F

T F

F

+ a

a + a Derivations:

๐ธ โŸน ๐ธ + ๐‘‡ โŸน ๐‘‡ + ๐‘‡ โŸน ๐‘‡ + ๐น โŸน ๐น + ๐‘Ž โŸน ๐‘Ž + ๐‘Ž

Question Two: 1 Mark

Give context-free grammars that generate the following languages. In all parts the alphabet E is {0,1}.

a. ๐ฟ = {๐‘ค|๐‘ค ๐‘ ๐‘ก๐‘Ž๐‘Ÿ๐‘ก๐‘  ๐‘Ž๐‘›๐‘‘ ๐‘’๐‘›๐‘‘๐‘  ๐‘ค๐‘–๐‘กโ„Ž ๐‘กโ„Ž๐‘’ ๐‘ ๐‘Ž๐‘š๐‘’ ๐‘ ๐‘ฆ๐‘š๐‘๐‘œ๐‘™}

b. ๐ฟ = {๐‘ค||๐‘ค| ๐‘–๐‘  ๐‘œ๐‘‘๐‘‘}

The Answer of Question Two:

a.

S0 โ†’ 0S10|1S11|ฮต S1 โ†’ 0S1|1S1|ฮต b.

S0 โ†’ 0S1|1S1

S1 โ†’ 00S1|01S1|10S1|11S1|ฮต

(3)

3 Question Three: 1 Mark

Answer each part for the following context-free grammar G.

๐‘น โ†’ ๐‘ฟ๐‘น๐‘ฟ | ๐‘บ ๐‘บ โ†’ ๐’‚๐‘ป๐’ƒ | ๐’ƒ๐‘ป๐’‚ ๐‘ป โ†’ ๐‘ฟ๐‘ป๐‘ฟ | ๐‘ฟ | ๐œบ

๐‘ฟ โ†’ ๐’‚ | ๐’ƒ

a.What are the terminals of ๐‘ฎ?

b.True or False: ๐‘ป โŸน ๐’‚๐’ƒ๐’‚.

c. True or False: ๐‘ป โŸน ๐‘ป.

d. Give three strings in ๐‘ณ(๐‘ฎ).

The Answer of Question Three a. The terminals of G are: a, b.

b. False.

c. False.

d. ab, ba, aab.

Good Luck my Lovely Students ๐Ÿ˜‰ T.Mariah Sami Ahmed Khayat

Teacher Assistant @ Adam University College [email protected]

Referensi

Dokumen terkait