BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2079 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2079, 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 2079 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Define the complexity classes P and NP. Explain NP-completeness and the concept of polynomial-time reduction with the example of the Satisfiability (SAT) problem.
Complexity Classes P and NP
Class P (Polynomial time): P is the set of all decision problems (languages) that can be decided by a deterministic Turing machine in time bounded by a polynomial in the input size . Formally, . These are the problems regarded as efficiently solvable. Examples: shortest path, sorting, primality testing, 2-SAT.
Class NP (Nondeterministic Polynomial time): NP is the set of decision problems that can be decided by a nondeterministic Turing machine in polynomial time, or equivalently the set of problems whose YES-instances have a certificate (proof) that can be verified by a deterministic TM in polynomial time. Examples: SAT, Hamiltonian cycle, vertex cover, subset-sum.
Clearly (a solver can ignore the certificate). Whether is the famous open problem.
Polynomial-Time Reduction
A language is polynomial-time (many-one / Karp) reducible to , written , if there is a function computable in polynomial time such that for every string :
If and , then . Reductions let us prove a new problem is hard by transforming a known hard problem into it.
NP-Completeness
A language is NP-complete if:
- , and
- NP-hardness: every language satisfies .
NP-complete problems are the hardest problems in NP: if any one of them has a polynomial-time algorithm, then . To prove a new problem is NP-complete we show and reduce a known NP-complete problem to ().
SAT and the Cook–Levin Theorem
Boolean Satisfiability (SAT): Given a Boolean formula over variables , decide whether there is a truth assignment making true.
- SAT NP: a satisfying assignment is a certificate; substituting it and evaluating takes polynomial time.
- Cook–Levin Theorem (1971): SAT is NP-complete. The proof shows that for any decided by a polynomial-time NTM , the entire accepting computation (a tableau of configurations) can be encoded by a Boolean formula of polynomial size that is satisfiable iff accepts . Hence for all .
Thus SAT was the first proven NP-complete problem; all other NP-completeness proofs (3-SAT, clique, vertex cover, etc.) follow by chains of polynomial reductions starting from SAT.
Minimize the given DFA using the partitioning (table-filling) method and explain each step of the minimization algorithm with a suitable example.
DFA Minimization by the Table-Filling (Partitioning) Method
Goal: Given a DFA , produce an equivalent DFA with the minimum number of states by merging indistinguishable states.
Two states are distinguishable if there exists a string such that exactly one of is final.
Algorithm (steps)
- Remove unreachable states from .
- Build a table of all unordered pairs .
- Basis: Mark as distinguishable if one is final and the other is non-final.
- Induction: For every unmarked pair and each symbol , if is already marked, mark .
- Repeat step 4 until no new pair gets marked.
- Merge every pair left unmarked — these are equivalent states — into a single state. Define transitions on the merged blocks; 's block is the start, blocks containing final states are final.
Worked Example
Consider DFA with states , alphabet , start , final :
| State | 0 | 1 |
|---|---|---|
| →A | B | C |
| B | B | D |
| C | B | C |
| D | B | E |
| E | B | C |
Basis: is final, all others non-final, so every pair containing is marked: .
Induction: Check remaining pairs.
- : same; same → not marked.
- : and is marked → mark .
- : ; ? marked ⇒ marked ⇒ marked.
- Continuing, the only pair that stays unmarked is .
Merge: and are equivalent → merge into state . Minimized DFA states: :
| State | 0 | 1 |
|---|---|---|
| →AC | B | AC |
| B | B | D |
| D | B | E |
| *E | B | AC |
This 4-state DFA is the minimal DFA equivalent to the original 5-state DFA.
Note: By the Myhill–Nerode theorem, the minimal DFA is unique up to renaming of states.
State and prove the Pumping Lemma for context-free languages. Use it to show that L = { a^i b^j c^k | i = j = k } is not context-free.
Pumping Lemma for Context-Free Languages
Statement: If is a context-free language, then there exists a constant (the pumping length) such that every string with can be written as
satisfying:
- ,
- (i.e. and are not both empty), and
- for all , .
Proof Sketch
Let for a CFG in Chomsky Normal Form with variables. Take . Any string with has a parse tree of height . Along the longest root-to-leaf path there are more than variable nodes, so by the pigeonhole principle some variable repeats. Let the upper derive and the lower derive , with . Then:
- Replacing the lower subtree by the upper one times gives , hence for all (condition 3).
- Because CNF rules branch into two, the repetition can be found within the bottom portion so (condition 1).
- The rule uses a binary production, so produces at least one symbol, giving (condition 2).
Showing is NOT Context-Free
Assume for contradiction is CFL with pumping length . Choose
Write with and .
Since , the substring spans at most two of the three symbol blocks (it cannot contain 's and 's simultaneously, because they are separated by b's).
Pump with , giving :
- If contains only 's and 's (or any mix avoiding ), then has more 's and/or 's but the same number of 's, so the counts are no longer equal.
- Symmetrically, if avoids 's, the number of 's stays while / counts increase.
In every case at least one symbol's count differs from the others, so . This contradicts the pumping lemma.
Conclusion: No such exists, therefore is not context-free.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Construct a DFA that accepts all binary strings ending with '00'.
DFA Accepting Binary Strings Ending in '00'
Let with .
- : no useful suffix yet (last symbol not a 0 toward goal),
- : the string so far ends in a single '0',
- : the string ends in '00' (accepting).
Transition table:
| State | 0 | 1 |
|---|---|---|
| → | ||
| * |
Start state ; accepting state .
Idea: On a '1' the suffix is broken, so go back to . On a '0' advance (); once in , a further '0' keeps it in (suffix still '00').
Check: 100 → (accept). 1001 → ends in (reject). Correct.
Explain epsilon-closure with a suitable example.
ε-closure
In an ε-NFA, the ε-closure of a state , written , is the set of all states reachable from using only ε (empty) transitions, including itself.
Formally it is the smallest set such that and if then every state in is also in . For a set of states , .
It is used in subset (NFA-to-DFA) construction and in defining the extended transition for ε-NFAs.
Example
Consider states with ε-moves: , , and has no ε-move.
- (reach then via ε).
- .
- (no outgoing ε-edge).
Thus from the machine can be in any of without consuming input.
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
Over , a string must contain a 0 somewhere and a 1 somewhere. A 0 and a 1 must appear in some order, so:
- First term: a appears before a .
- Second term: a appears before a .
Together they cover every string having at least one 0 and at least one 1.
Equivalent compact form (complement of "all 0's or all 1's"):
Examples accepted: 01, 10, 1100, 0110. Rejected: 000, 111, \varepsilon.
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 uniqueness.)
Use: Finding a Regular Expression from a Finite Automaton
For a DFA/NFA, write one equation per state describing the set of strings that lead from the start state into (or, in the alternative formulation, from to a final state):
Wherever an equation has the self-referential form , apply Arden's theorem to replace it by . Substituting back and repeatedly eliminating variables, the equation for the final state(s) yields a regular expression equal to of the languages, i.e. .
Short Example
FA: start with , , final. Equations: , . Apply Arden's to (here , ): . Then . So .
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 that has two or more distinct parse trees (equivalently, two distinct leftmost — or two distinct rightmost — derivations). Ambiguity is a property of the grammar, not the language.
Example
Consider the expression grammar:
Take the string .
Parse tree 1 (treats as outer operator — corresponds to ):
E
/ | \
E + E
| /|\
id E * E
| |
id id
Leftmost derivation: .
Parse tree 2 (treats as outer operator — corresponds to ):
E
/ | \
E * E
/|\ |
E + E id
| |
id id
Leftmost derivation: .
The same string has two different parse trees / leftmost derivations, so the grammar is ambiguous. (Ambiguity here can be removed by introducing precedence/associativity via separate non-terminals for term and factor.)
Eliminate left recursion from the grammar A -> Aa | b.
Eliminating Left Recursion from
The production is immediately left-recursive because the right side begins with the non-terminal itself.
General rule: For (where does not start with ), rewrite as
Here and . Introducing a new non-terminal :
Verification: The original generates (a followed by zero or more 's). The new grammar: , also generating . The languages match and the new grammar is right-recursive (no left recursion), suitable for top-down (LL) parsing.
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 non-terminals (). Thus each production starts with exactly one terminal followed by zero or more variables. (For a language containing , is allowed with not on any RHS.)
GNF guarantees each derivation step generates exactly one terminal symbol, which is useful for showing CFL = NPDA and for top-down parsing.
Conversion Procedure
- Convert to Chomsky Normal Form (CNF) first: remove ε-productions, unit productions, and useless symbols, and ensure productions are or .
- Order the non-terminals .
- Remove left recursion / substitute so that every production has : for each , for each , substitute the productions of into . Then eliminate any immediate left recursion on by introducing a new variable ( becomes , ).
- After this, 's productions already start with a terminal. Back-substitute: working downward ( and the ), replace a leading non-terminal at the start of any RHS by its productions, so every production begins with a terminal.
Small Example
. Substitute into : . Now all productions () begin with a terminal — GNF achieved.
Define instantaneous description (ID) of a PDA and explain acceptance by final state and by empty stack.
Instantaneous Description (ID) of a PDA
A pushdown automaton is . An instantaneous description (ID) is a triple that captures the complete configuration of the PDA at a moment in time:
where
- is the current state,
- is the remaining (unread) input, and
- is the current stack contents (top written leftmost).
A move between IDs is written with the turnstile :
denotes zero or more moves. The initial ID is .
Acceptance by Final State
The language accepted by final state is
The input is accepted if, after consuming the whole input, the PDA is in some final state — the stack contents are irrelevant.
Acceptance by Empty Stack
The language accepted by empty stack is
The input is accepted if, after consuming the whole input, the stack becomes empty — the final state is irrelevant ( is typically taken as ).
Equivalence: The two acceptance modes accept exactly the same class of languages (the context-free languages); a PDA of one type can be converted to one of the other.
Explain the working of a multi-tape Turing Machine.
Multi-Tape Turing Machine
A multi-tape Turing machine is a TM equipped with semi-infinite (or two-way infinite) tapes, each with its own independent read/write head. It is a convenient model that is equivalent in power to the standard single-tape TM.
Components / Working
- It has a finite control (set of states), and tapes; tape 1 initially holds the input, the other tapes are blank.
- In one move, depending on the current state and the symbols currently scanned (one per tape), the machine:
- Writes a symbol on each of the tapes (independently),
- Moves each of the heads independently Left, Right, or Stays (L/R/S), and
- Enters a new state.
- The transition function has the form
- Acceptance is by entering an accept (halt) state, as usual.
Advantage
Separating data onto different tapes makes algorithm design much simpler (e.g. one tape for input, one as a counter/scratchpad). It can speed computation up by a polynomial factor.
Equivalence with Single-Tape TM
Any -tape TM can be simulated by a single-tape TM : stores the tape contents on one tape using tracks — tracks for the symbols and tracks marking each head position. To simulate one move of , sweeps across to read all marked symbols, then sweeps back updating symbols and head markers. Hence multi-tape TMs recognize exactly the recursively enumerable languages — the same class as single-tape TMs — though a single-tape simulation of steps may take time.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2079?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2079 (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) 2079 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) 2079 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2079 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.