Skip to content
VUBuddy

CS606 Short Notes Lecture 8

Compiler Construction PDF 30 KBUpdated 23 Oct 2026
Quiz CS606 Short Notes Lecture 8 PDF 30 KB
vubuddy.com
Type
Quiz
Course
CS606 Compiler Construction
Size
PDF 30 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 30 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2 of 3. Download the file for all 3 pages.

Lecture 8

NFA ? DFA Construction

The algorithm is called subset construction. In the transition table of an NFA, each entry is a set of states. In DFA, each entry is a single state. The general idea behind NFA-toDFA construction is that each DFA state corresponds to a set of NFA states. The DFA uses its state to keep track of all possible states the NFA can be in after reading each

We will use the following operations.

  • ε-closure(T): set of NFA states reachable from some NFA state s in T on ? -transitions alone.
  • move(T,a): set of NFA states to which there is a transition on input a from some NFA state s in set of states T.

Before it sees the first input symbol, NFA can be in any of the state in the set ε-closure(s0), where s0 is the start state of the NFA. Suppose that exactly the states in set T are reachable from s0 on a given sequence of input symbols. Let a be the next input symbol. On seeing a, the NFA can move to any of the states in the set move(T,a). Let a be the next input symbol. On seeing a, the NFA can move to any of the states in the set move(T,a). When we allow for ε-transitions, NFA can be in any of the states in ε-closure(move(T,a)) after seeing a.

Subset Construction

Algorithm:

Input: NFA N with state set S, alphabet Σ, start state s0, final states F Output: DFA D with state set S’, alphabet Σ, start states, s0’ = ε-closure(s0), final states F’ and transition table: S’ x Σ ? S’

// initially, e-closure(s0) is the only state in D states S’ and it is unmarked s0’ = ε-closure(s0) S’ = {s0’ } (unmarked)

while (there is some unmarked state T in S’) mark state T for all a in Σ do U = ? εclosure( move(T,a) ); if U not already in S’ add U as an unmarked state to S’ Dtran(T,a) = U; end for end while F’: for each DFA state S if S contains an NFA final state mark S as DFA final state

end algorithm

Example

Let us apply the algorithm to the NFA for (a | b )*abb. Σ is {a,b}.

0 ε ε

ε ε ε

a

b

ε

ε ε 7 a

b

b 10

The start state of equivalent DFA is ε-closure(0), which is A = {0,1,2,4,7}; these are exactly the states reachable from state 0 via ε-transition. The algorithm tells us to mark A and then compute ε-closure(move(A,a))

move(A,a)), is the set of states of NFA that have transition on ‘a’ from members of A. Only 2 and 7 have such transition, to 3 and 8. So, ε-closure(move(A,a)) = ε-closure({3,8}) = {1,2,3,4,6,7,8}. Let B = {1,2,3,4,6,7,8}; thus Dtran[A,a] = B

For input b, among states in A, only 4 has transition on b to 5. Let C = ε-closure({5}) = {1,2,4,5,6,7}. Thus, Dtran[A,b] = C

We continue this process with the unmarked sets B and C, i.e., ε-closure(move(B,a)), ε-closure(move(B,b)), ε-closure(move(C,a)) and ε-closure(move(C,b)) until all sets and states of DFA are marked. This is certain since there are only 211 (!) different subsets of a set of 11 states. A set, once marked, is marked forever. Eventually, the 5 sets are:

  1. A={0,1,2,4,7}
  2. B={1,2,3,4,6,7,8}
  3. C={1,2,4,5,6,7}
  4. D={1,2,4,5,6,7,9}
  5. E={1,2,4,5,6,7,10}

A is start state because it contains state 0 and E is the accepting state because it contains state 10.

All CS606 files →
CS606 Compiler Construction All CS606 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.