COS3701 assignment 1 semester
COURSE: THEORETICAL COMPUTER SCIENCE III COURSE CODE: COS3701 SEMESTER: 2021 01 ASSIGNMENT: 01 UNIQUE NUMBER: DUE DATE: 15TH COS3701 assignment 1 semester 1 COS3701 REG. NO UNIQUE NO: Page 1 of 10 1. Problem 3(ii) on page 255. Consider the CFG S → XaXaX X → aX|bX|Λ What is the language this CFG generates? This CFG can generate (a+b)*a(a+b)*a(a+b)*. We can thus verify the language as follows: ▪ The CFG S → XaXaX only generates words that contain as, therefore the grammar only generates words in L. ▪ We select any word in L and write it down as y1ay2ay3 where yi(1 ≤ i ≤ 3) can be a string in as and bs. Taking S → XaXaX, we indicate the right side by X1aX2aX3 and then confirm if the first letter of yi(1 ≤ i ≤ 3) is an a. We can now confirm the production Xi → aXi and if the first letter is a b, then apply production Xi → bXi. We then apply the same to the successive letters until we finally apply Xi → Ʌ to remove X. This is applied to y1, y2 and y3 to get the word y1ay2ay3. Given that this is a word in L, it therefore indicates that the grammar can generate all words in L. 2. Problem 8(v) on pa
Información del documento
- Subido en
- 13 de abril de 2022
- Número de páginas
- 11
- Escrito en
- 2021/2022
- Tipo
- Examen
- Contiene
- Preguntas y respuestas