TCS Theory Questions
TCS Theory Questions
TCS Theory Questions
1. Lexical Analysis:
One of the major applications of regular expressions is in specifying the component called “lexical
analyzer”. This component scans the source program and recognizes all tokens, those substrings of
consecutive characters that belong together logically. Keywords and identifiers are common examples of
tokens.
2. Finding patterns in text:
Regular expression gives a “picture” of the pattern we want to recognize. By using regular expressions, it
becomes easy to describe the patterns at a high level with little effort and to modify the description quickly
when things go wrong. The regular are the then compiled into DFA or NFA which are then simulated to
produce program that recognizes patterns in text.
Q) Applications of FA:
1) Lexical Analyzer:
Lexical Analyzer (which performs one of the phases of Compilation i.e. Lexical Analysis) groups the series
of characters into one of these token types (which can be identifier, operator symbol, punctuation symbol,
etc). The set of words belonging to a particular token type is a regular language. Hence each of these token
types can be specified using regular expressions.
Example: consider the token Identifiers Identifier
can be defined by regular expression as
r = (letter). (letter | digit)*
letter = A | B | …|Z | a | b|… | z
digit = 0 |1 |…| 9
So one can specify all the token types using regular expressions. These regular expressions are then
converted into a DFAs.
2) Searching using Regular Expressions in Text Editors:
Many operating systems provide search utilities to perform frequent and complex jobs. The search command
simulates the finite automata corresponding to the regular expressions (i.e the word to be searched).
Q) Recursive Language:
A language L over the alphabet is called recursive if there is a TM T that accepts every word in L and
rejects every word in L.
i.e. Accept (T) = L
reject (T) = L
loop (T) =
Example: TM accepting L over Σ = {a, b} that starts with a and rejects all other. So L Language is recursive.
Q) Recursively Enumerable Language:
A language L over the alphabet is called r.e. if there is a TM T that accepts every word in L and either
rejects or loops for every word in language L.
i.e. Accept(T) = L
Q) Rice’s Theorem:
Q) Halting Problem:
For a given configuration of a TM two cases can arise:
• the machine starting at this configuration will halt after a finite number of steps.
• the machine starting at this configuration never halts no matter how long it runs.
Given any TM, problem of determining whether it halts ever or not, is called as halting problem.