BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2074 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2074, as set in the regular annual examination. It carries 60 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this Theory of Computation (BSc CSIT, CSC257) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) exam or solving previous years' question papers, this 2074 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Define finite automata. Construct a DFA that accepts all strings over {0, 1} having an even number of 0's and an even number of 1's. Show the transition table and transition diagram.
Finite Automata
A Finite Automaton (FA) is an abstract mathematical model of a machine with a finite amount of memory used to recognize regular languages. Formally, a Deterministic Finite Automaton (DFA) is a 5-tuple:
where:
- = finite set of states
- = finite input alphabet
- = transition function
- = start state
- = set of accepting (final) states
DFA for even number of 0's and even number of 1's
We track parity of 0's and parity of 1's. There are four combinations, giving four states:
- = (even 0's, even 1's) — start and accepting
- = (odd 0's, even 1's)
- = (even 0's, odd 1's)
- = (odd 0's, odd 1's)
Reading a 0 flips the 0-parity; reading a 1 flips the 1-parity.
Transition Table
| State | 0 | 1 |
|---|---|---|
( = start state, = final state). .
Transition Diagram (described)
Four states arranged as a square. Horizontal edges (labelled 0) connect and (toggling 0-parity). Vertical edges (labelled 1) connect and (toggling 1-parity). has an incoming start arrow and is drawn with a double circle (accepting).
Example: string 0011 — , ends in → accepted (two 0's, two 1's, both even). String 010 ends in → rejected.
What is a Non-deterministic Finite Automaton (NFA)? Construct an NFA that accepts the set of strings over {0, 1} ending with '01' and convert it into an equivalent DFA using the subset construction method.
Non-deterministic Finite Automaton (NFA)
An NFA is a 5-tuple where the transition function maps a state and an input symbol to a set of states:
From a given state on a given symbol an NFA may move to zero, one, or several states (non-determinism). A string is accepted if some sequence of choices leads to a final state. NFAs accept exactly the regular languages, the same class as DFAs.
NFA for strings ending with 01
NFA Transition Table
| State | 0 | 1 |
|---|---|---|
loops on 0 and 1 (guessing the rest of the string), branches to on a 0, then on the following 1.
Subset Construction (NFA → DFA)
Start from and compute reachable subsets.
| DFA State | 0 | 1 |
|---|---|---|
Accepting states: any subset containing , i.e. . .
Resulting DFA
- States:
- Start: , Final:
Diagram (described): on 0 → , on 1 → (self-loop). on 0 → (self-loop), on 1 → . (double circle) on 0 → , on 1 → .
Check: 001 → → accepted.
State and prove the Pumping Lemma for regular languages. Using it, prove that the language L = { a^n b^n | n >= 0 } is not regular.
Pumping Lemma for Regular Languages
Statement. If is a regular language, then there exists a constant (the pumping length) such that every string with can be written as satisfying:
- (the middle part is non-empty),
- ,
- for all .
Proof (sketch)
Since is regular, there is a DFA with states accepting . Take any with . While reading , visits states, so by the pigeonhole principle some state is repeated within the first symbols. Let:
- = prefix read before first visiting ,
- = part read on the loop from back to (, and ),
- = remainder.
The loop labelled can be traversed any number of times, so also accepts for every . Hence the three conditions hold.
Proving is not regular
Proof by contradiction. Assume is regular with pumping length .
Choose , with . By the lemma with and .
Because , the substring lies entirely within the first symbols, which are all 's. Therefore for some .
Pump with :
Since , this string has more 's than 's, so . This contradicts condition (3) of the pumping lemma.
Therefore the assumption is false, and is not regular.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Define alphabet, string, and language with examples.
- Alphabet (): a finite, non-empty set of symbols. Example: (binary alphabet); .
- String (word): a finite sequence of symbols drawn from an alphabet. The empty string is denoted and has length 0. Example: over ,
0110is a string of length 4; is the empty string. - Language: a set of strings over an alphabet, i.e. any subset of (the set of all strings over ). A language may be finite or infinite. Example: , or .
Differentiate between DFA and NFA.
DFA vs NFA
| Feature | DFA | NFA |
|---|---|---|
| Transition function | (single next state) | (set of states) |
| Moves per (state, symbol) | Exactly one | Zero, one, or many |
| -transitions | Not allowed | Allowed (in -NFA) |
| Determinism | Deterministic — next move uniquely defined | Non-deterministic — may have choices |
| Acceptance | Unique path; accept if it ends in a final state | Accept if some path ends in a final state |
| Number of states | Generally more | Generally fewer / easier to design |
| Implementation | Directly implementable | Must usually be converted to DFA |
Important: despite the differences, DFA and NFA have equal expressive power — both accept exactly the class of regular languages, and every NFA can be converted to an equivalent DFA via subset construction (with up to states).
Construct a DFA that accepts all binary strings ending with '00'.
DFA accepting binary strings ending with 00
Track how many trailing 0's have been seen (0, 1, or ).
- : last symbol was not part of a
00suffix (start; no relevant trailing 0) - : string currently ends in exactly one
0 - : string ends in
00— accepting
Transition Table
| State | 0 | 1 |
|---|---|---|
Reading a 1 always resets to (suffix broken). In , another 0 keeps the ...00 suffix, so it self-loops.
Diagram (described): ; self-loops on 0; every 1 arrow goes back to . is a double circle.
Check: 1100 → → accepted.
Explain epsilon-closure with a suitable example.
-closure
For an NFA with -transitions, the -closure of a state , written (or ), is the set of all states reachable from using zero or more (empty) transitions only (no input symbol consumed). For a set of states, the -closure is the union of the closures of its members. Every state is always in its own -closure.
It is used when simulating -NFAs and when converting an -NFA to a DFA.
Example
Consider the -transitions:
Then:
- (reach directly, via )
Write a regular expression for strings over {0,1} that contain at least one '0' and at least one '1'.
Regular expression: at least one 0 and at least one 1
The string must contain a 0 somewhere and a 1 somewhere (in either order). One standard answer, splitting on which symbol appears first:
- The first term covers strings where a
0occurs before some later1. - The second term covers strings where a
1occurs before some later0.
Together they describe exactly the strings over containing at least one 0 and at least one 1.
(Equivalently, this is , i.e. all strings except those made only of 0's or only of 1's, including .)
Examples accepted: 01, 10, 0011, 1010. Rejected: , 000, 111.
State Arden's theorem and explain its use in obtaining a regular expression from a finite automaton.
Arden's Theorem
Statement. Let and be regular expressions over an alphabet, where does not contain the empty string (i.e. ). Then the equation
has the unique solution
The condition guarantees the solution is unique.
Use: deriving a regular expression from a finite automaton
Given a DFA/NFA, Arden's theorem lets us solve the automaton's state equations:
- For each state , write an equation expressing it as the sum of for every incoming transition. The start state's equation also includes a term.
- This yields a system of simultaneous regular-expression equations.
- Solve by substitution, repeatedly applying Arden's rule to eliminate self-loops/recursion.
- The regular expression for the final state (sum of expressions for all final states) is the language accepted by the automaton.
Mini-example
For a state with (self-loop on ), Arden gives .
What is an ambiguous grammar? Show with an example that a grammar is ambiguous.
Ambiguous Grammar
A context-free grammar is ambiguous if there exists at least one string in that has two or more distinct parse trees (equivalently, two distinct leftmost derivations, or two distinct rightmost derivations).
Example
Consider the grammar for arithmetic expressions:
Take the string id + id * id. It has two different leftmost derivations / parse trees:
Derivation 1 (treats first):
Parse tree groups as .
Derivation 2 (treats first):
Parse tree groups as .
Since the single string id + id * id has two distinct parse trees, the grammar is ambiguous. (It can be made unambiguous by introducing precedence levels using terms and factors.)
Eliminate left recursion from the grammar A -> Aa | b.
Eliminating Left Recursion from
General rule. For a grammar with immediate left recursion of the form
(where does not begin with ), replace it by the right-recursive grammar:
Applying to : here and . Substituting:
Verification. The original grammar generates (a followed by zero or more 's). The new grammar also generates then any number of 's, e.g. baa: . The languages are equal, and there is no longer any left recursion.
Explain the conversion of a CFG into Greibach Normal Form (GNF).
Greibach Normal Form (GNF)
A CFG is in Greibach Normal Form if every production has the form
where is a single terminal and is a (possibly empty) string of variables only (). Thus every production begins with exactly one terminal. (If , the production is also permitted.)
Conversion Procedure
Given a CFG (with no -productions except possibly , no unit productions, no useless symbols):
- Convert to Chomsky Normal Form (CNF) first — productions or . Remove -, unit, and useless productions along the way.
- Order the variables .
- Remove forward recursion: for each production with , substitute every production of for the leading , so that the leading variable's index is not smaller. Repeat until every production starts with a higher-indexed variable or a terminal.
- Eliminate immediate left recursion of the form by introducing a new variable (right-recursion conversion).
- Back-substitute: now 's productions start with a terminal. Substitute these into so every production begins with a terminal.
- Fix the new variables similarly so their productions also begin with terminals.
- Replace any leading-position terminal that is followed by terminals by introducing variables, so each production becomes with over variables only.
The result is an equivalent grammar in GNF. GNF is useful because every derivation step produces exactly one terminal, so a string of length derives in exactly steps, and GNF directly relates CFGs to pushdown automata.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2074?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2074 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
- Does the Theory of Computation (BSc CSIT, CSC257) 2074 paper come with solutions?
- Yes. Every question on this Theory of Computation (BSc CSIT, CSC257) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
- How many marks is the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2074 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2074 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
- Is practising this Theory of Computation (BSc CSIT, CSC257) past paper free?
- Yes — reading and attempting this Theory of Computation (BSc CSIT, CSC257) past paper on Kekkei is completely free.