BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2080 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2080, 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 2080 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
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 finite automaton defined by the 5-tuple where:
- = finite set of states
- = input alphabet
- is the transition function (it maps to a set of states)
- = start state
- = set of final (accepting) states
Unlike a DFA, from a given state on a given symbol an NFA may move to zero, one, or several states. A string is accepted if at least one computation path ends in a final state.
NFA for strings over {0,1} ending with '01'
States: (start), (seen 0), (seen 01, final).
| State | on 0 | on 1 |
|---|---|---|
The self-loop on (for both 0 and 1) lets the automaton guess where the suffix 01 begins; recognises the final 01. is the only accepting state.
Conversion to DFA (Subset Construction)
We build DFA states as subsets of NFA states. Start = .
| DFA state | on 0 | on 1 |
|---|---|---|
Resulting DFA:
- States:
- Start state:
- Accepting state: (since contains the NFA final state )
- Transitions as in the table above.
This DFA accepts exactly the strings over ending in 01.
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 every .
Proof
Since is regular, some DFA with states accepts . Take any with . Reading visits states. By the pigeonhole principle, among the first visited states some state repeats while reading the first symbols.
Let the first visit to be after reading and the second after reading (so the loop reads , , and ). The remaining input is . Because takes from back to , the loop can be traversed any number of times. Hence is also accepted for all , i.e. .
Proving is not regular
Assume, for contradiction, that is regular with pumping length .
Choose , and . By the lemma with and .
Since , both and lie entirely within the leading 's, so for some .
Now pump with :
Here the number of 's () exceeds the number of 's (), so .
This contradicts the pumping lemma. Therefore is not regular.
Define context-free grammar (CFG). Convert the following CFG into an equivalent grammar in Chomsky Normal Form (CNF): S -> ASA | aB, A -> B | S, B -> b | epsilon.
Context-Free Grammar (CFG)
A CFG is a 4-tuple where is a finite set of variables (non-terminals), is a finite set of terminals (), is the start symbol, and is a finite set of productions of the form with and . The language generated is the set of terminal strings derivable from .
Chomsky Normal Form (CNF): every production is (two variables) or (single terminal); is allowed only if .
Converting the given CFG to CNF
Grammar:
Step 1: Add a new start symbol
Step 2: Remove -productions
Nullable variable: (since ), and hence (since ). Remove and add versions of rules with nullable symbols omitted.
- : dropping nullable 's gives . Drop the unit . So .
- : gives .
- stays; would appear (A nullable) but we drop it.
Result:
Step 3: Remove unit productions
Unit pairs: , , .
- (from ), and (from ).
Result:
Step 4: Replace terminals in long rules
Introduce . Replace a in by : .
Step 5: Break rules longer than two symbols
For each introduce , so with .
Final CNF Grammar
Every production now has the form or , so the grammar is in Chomsky Normal Form.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Explain the closure properties of regular languages.
Closure Properties of Regular Languages
The class of regular languages is closed under the following operations: if and are regular, then so are the results below.
- Union: is regular (combine the two FAs with a new start state via -moves, or take the union of their regular expressions ).
- Concatenation: is regular (connect final states of to start of by ; regex ).
- Kleene Star: is regular (add -loop back from finals to start).
- Intersection: is regular (product/cross-product DFA construction).
- Complement: is regular (swap accepting and non-accepting states of a complete DFA).
- Difference: is regular.
- Reversal: is regular (reverse all transitions, swap start/final).
- Homomorphism and inverse homomorphism also preserve regularity.
These closure properties are useful for proving languages regular/non-regular and for combining automata in lexical analysis.
What is the membership problem? Explain the CYK algorithm in brief.
Membership Problem
The membership problem asks: given a grammar (or automaton) and a string , decide whether . For context-free languages this is decidable — the CYK algorithm answers it efficiently.
CYK Algorithm (Cocke–Younger–Kasami)
CYK is a dynamic-programming, bottom-up parsing algorithm that decides membership for a CFG in Chomsky Normal Form. For a string :
- Build a triangular table where holds the set of variables that derive the substring of length starting at position .
- Base case (length 1): .
- Recursive case: for length from 2 to , for each split point , set
- Accept if the start symbol .
It runs in time, confirming CFG membership is decidable.
Construct an NFA for the regular expression (0+1)*1.
NFA for
This regular expression denotes all strings over that end with 1.
States: (start), (final).
| State | on 0 | on 1 |
|---|---|---|
Description: has self-loops on both 0 and 1, modelling the part. On reading a 1, the NFA may also move to the accepting state , modelling the final 1. A string is accepted iff some path lands in after the last symbol — which happens exactly when the last input symbol is 1.
- , start , , .
Explain Rice's theorem in brief.
Rice's Theorem
Statement. Every non-trivial semantic property of the language recognised by a Turing machine is undecidable.
More precisely, let be a property of recursively enumerable languages (i.e. a property of the language , not of the machine's internal structure). is non-trivial if some TM-recognisable language has the property and some other does not. Then the problem "Does have property ?" is undecidable.
Key points:
- The property must be about the language (behaviour), not about syntax/states (e.g. "M has 5 states" is not covered).
- Non-trivial means is neither always true nor always false over all RE languages.
Examples of undecidable problems (by Rice): Is ? Is regular? Is finite? Does accept a particular string ? All are undecidable.
Rice's theorem is a powerful generalisation of the halting problem, showing that essentially nothing interesting about a TM's language can be decided algorithmically.
Define alphabet, string, and language with examples.
Alphabet, String, and Language
Alphabet (): a finite, non-empty set of symbols. Example: (binary alphabet), or .
String (word): a finite sequence of symbols drawn from an alphabet. The empty string is denoted (length 0). The length of string is written .
Example: over , 0110 is a string with ; is also a string.
Language: a set of strings over an alphabet, i.e. any subset of (where is the set of all strings over ). A language may be finite or infinite. Example: over :
- — a finite language.
- — an infinite language.
- over .
Thus: symbols form an alphabet, sequences of symbols form strings, and sets of strings form languages.
Differentiate between DFA and NFA.
Difference between DFA and NFA
| Feature | DFA (Deterministic) | NFA (Non-deterministic) |
|---|---|---|
| Transition function | (single next state) | (set of states) |
| Next move | Exactly one state per (state, symbol) | Zero, one, or many states |
| -transitions | Not allowed | Allowed |
| Acceptance | Unique path; accept if it ends in a final state | Accept if some path ends in a final state |
| Construction | Harder to design | Easier / more intuitive to design |
| Number of states | May need more states | Usually fewer states |
| Backtracking | Not required | May need to explore multiple paths |
| Power | Equivalent — both recognise exactly the regular languages | Equivalent (convertible to DFA via subset construction) |
Key point: Although NFAs appear more powerful, every NFA can be converted to an equivalent DFA, so both accept exactly the same class of languages (regular languages).
Construct a DFA that accepts all binary strings ending with '00'.
DFA Accepting Binary Strings Ending with '00'
We track how many trailing 0s have been seen.
States: (no useful suffix / last symbol not contributing), (string ends in a single 0), (string ends in 00, accepting).
| State | on 0 | on 1 |
|---|---|---|
- , start , , .
Logic:
- Reading
1always resets to (no trailing zeros). - Reading
0from goes to (one trailing zero); from to (two or more); from stays in (still ends in00).
The DFA accepts iff it ends in , i.e. the string ends with 00. Example: 100 is accepted; 010 is rejected.
Explain epsilon-closure with a suitable example.
Epsilon-Closure
In an NFA with -transitions, the -closure of a state , written or , is the set of all states reachable from using zero or more -transitions (including itself).
Formally:
- .
- If and there is an -transition , then .
It is used when simulating -NFAs and when converting an -NFA to a DFA.
Example
Consider an -NFA with transitions:
Then:
- (reach via one , then via another).
- .
- (no outgoing -moves).
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
For strings over containing at least one 0 AND at least one 1, account for the two possible orderings (the first 0 may come before or after the first 1):
Explanation:
- The first term matches strings where a
0appears somewhere before a1. - The second term covers the case where a
1appears before a0. - Their union guarantees the string has both at least one
0and at least one1, in either order.
Examples accepted: 01, 10, 0011, 1010. Rejected: 000, 111, \epsilon (each lacks one of the symbols).
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2080?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2080 (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) 2080 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) 2080 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2080 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.