CS402 Assignment 1 2024
CS402 Assignment 1 2024
Bibi
Student id:
bc210411376
Subject: CS402
Assignment# 1: 2024
Question No 01 Marks:
3+3+3 = 9
Consider the language L of strings, defined over ∑= {a, b}, Write regular expressions of following:
· Strings starting with “b” and ending with “a” having “ab” as a substring.
· Strings containing even number of a’s and ending with “baba” or “bb”.
· String that having NULL or starts with “a” and having no consecutive b’s in it.
Solution:
In automata theory, a regular expression (RE) is a string on Σ, or a language or string accepted by a finite
automata. A finite automata is made up of five tuples: {Q, Σ, δ, q0, F}. REs are a sequence of patterns
that define a string and are used to match character combinations in strings. For example, in a regular
expression, x* means zero or more occurrences of x.
Part(A)
Regular expression: b(ab)*a
Explanation:
b . Ensures the strings starts with b.
Explanation:
(aa))* allows for zero or more occurences of the substrings "a" ensures the even number of a's
Part (c)
Regular expression: ε|(a(ε|ba)*)
Explanation:
ε Represent the empty strings or Null.
(ε|ba) allows for zero or more occurences of either an empty strings or the substring of "ba"
Question No 2:
Marks: 11