0% found this document useful (0 votes)
218 views

CS402 Assignment 1 2024

Uploaded by

rehanabbasi7650
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

CS402 Assignment 1 2024

Uploaded by

rehanabbasi7650
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Student name: Laiba

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.

(ab). Allows for zero or more occurences of the substring "ab"

a. ensures the strings end with with "a".


Part (B):
Regular expression: ((aa))*baba)|((aa)*bb)

Explanation:
(aa))* allows for zero or more occurences of the substrings "a" ensures the even number of a's

baba. Ensures the strings end with 'baba'

bb. alternatively , ensures the strings end with "bb".

Part (c)
Regular expression: ε|(a(ε|ba)*)

Explanation:
ε Represent the empty strings or Null.

a. ensures the strings start with "a.

(ε|ba) allows for zero or more occurences of either an empty strings or the substring of "ba"

"ba" this ensures there are no consective b's.

Question No 2:
Marks: 11

Construct a Deterministic Finite Automata (DFA) for part C of Question 1.

You might also like