BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2078 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2078, 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 2078 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
State the Halting Problem of a Turing Machine. Prove that the Halting Problem is undecidable. Differentiate between decidable and undecidable problems with examples.
Halting Problem of a Turing Machine
The Halting Problem asks: Given an arbitrary Turing machine and an input string , does halt (stop) on input ?
Formally, define the language
The Halting Problem is to decide membership in .
Proof that the Halting Problem is Undecidable
We prove undecidability by contradiction (diagonalization).
- Assume there exists a Turing machine that decides the Halting Problem. That is, for every :
- Using , construct a new machine that takes a single TM description as input and behaves as follows:
D(<M>):
run H(<M>, <M>) # does M halt on its own description?
if H accepts: loop forever
if H rejects: halt (accept)
Thus does the opposite of what does on its own encoding.
- Now run on its own description :
- If halts on , then said "halts", so by construction loops — contradiction.
- If loops on , then said "loops", so by construction halts — contradiction.
Either case is a contradiction, so the assumed decider cannot exist. Therefore the Halting Problem is undecidable. (It is, however, recursively enumerable / semi-decidable — a TM can simulate on and accept if it halts.)
Decidable vs. Undecidable Problems
| Aspect | Decidable | Undecidable |
|---|---|---|
| Definition | A problem for which a TM exists that always halts with the correct yes/no answer | No TM can decide it; any TM may loop forever on some inputs |
| Language class | Recursive | Not recursive |
| Guarantee | Algorithm always terminates | No terminating algorithm exists |
| Examples | Membership of a string in a regular/CFL language; whether a DFA accepts a string; emptiness of a DFA | Halting Problem; whether for a TM; Post Correspondence Problem; whether two CFGs are equivalent |
In short: decidable problems have total deciders; undecidable problems (like the Halting Problem) have none.
Explain the Chomsky hierarchy of languages with the corresponding grammars and recognizing machines. Discuss the closure properties of context-free languages.
Chomsky Hierarchy of Languages
Noam Chomsky classified formal grammars/languages into four nested types by restrictions on production rules. Each type corresponds to a class of grammar and an abstract machine that recognizes it.
| Type | Language Class | Grammar (production form) | Recognizing Machine |
|---|---|---|---|
| Type 0 | Recursively Enumerable | Unrestricted: , | Turing Machine |
| Type 1 | Context-Sensitive | , $ | \text{LHS} |
| Type 2 | Context-Free | (single non-terminal LHS) | Pushdown Automaton (PDA) |
| Type 3 | Regular | or (right-linear) | Finite Automaton (DFA/NFA) |
The containment is strict: .
Closure Properties of Context-Free Languages
Let be context-free languages.
CFLs are CLOSED under:
- Union: — combine grammars with new start symbol .
- Concatenation: — use .
- Kleene star: — use .
- Substitution and homomorphism.
- Intersection with a regular language: is context-free (product of PDA and DFA).
- Reversal: .
CFLs are NOT CLOSED under:
- Intersection: e.g. and are CFLs but is not context-free.
- Complementation: follows from non-closure under intersection (since and CFLs are closed under union).
- Set difference in general.
These properties are central to deciding whether a language is context-free.
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
-
P (Polynomial time): the class of decision problems solvable by a deterministic Turing machine in time for some constant , where is the input size. These are the efficiently solvable (tractable) problems. Examples: sorting, shortest path, primality testing.
-
NP (Nondeterministic Polynomial time): the class of decision problems for which a proposed solution (certificate) can be verified by a deterministic TM in polynomial time; equivalently, problems solvable by a nondeterministic TM in polynomial time. Examples: SAT, Hamiltonian cycle, subset-sum.
Clearly (a problem that can be solved quickly can be verified quickly). Whether is the most famous open problem in computer science.
Polynomial-Time Reduction
A language is polynomial-time reducible to , written , if there is a function computable in polynomial time such that
Meaning: an efficient algorithm for yields an efficient algorithm for . Reductions transfer hardness: if and , then .
NP-Completeness
A language is NP-complete if:
- , and
- Every language satisfies (NP-hardness).
NP-complete problems are the hardest in NP: if any one of them is in , then .
SAT (Satisfiability) Example
The SAT problem asks whether a given Boolean formula (e.g. in CNF) has an assignment of truth values making it true.
- SAT is in NP: given a truth assignment (certificate), we can evaluate the formula in polynomial time to verify satisfaction.
- Cook–Levin Theorem: SAT is NP-complete — it was the first problem proved NP-complete by showing that the computation of any polynomial-time NDTM on an input can be encoded as a Boolean formula that is satisfiable iff the machine accepts.
Because SAT is NP-complete, it serves as the canonical starting point for proving other problems NP-complete: to show a new problem is NP-hard, we exhibit a polynomial-time reduction (e.g. SAT 3-SAT Clique Vertex Cover).
Section B: Short Answer Questions
Attempt any EIGHT questions.
What is a Universal Turing Machine? Explain its significance.
Universal Turing Machine (UTM)
A Universal Turing Machine is a single Turing machine that can simulate the behaviour of any other Turing machine on any input . It takes as input an encoding of the machine together with the input string , i.e. the pair , and then simulates step by step:
If accepts , accepts; if rejects, rejects; if loops, loops.
Significance
- Stored-program concept: The UTM treats a program (the description ) as data on its tape — the theoretical basis for modern general-purpose, stored-program computers (von Neumann architecture).
- Programmability: A single fixed machine can perform any computation simply by changing its input, rather than building a new machine per task.
- Foundation for undecidability: The existence of a UTM makes self-reference possible and underlies proofs that the Halting Problem and the language are undecidable.
- It confirms the Church–Turing thesis that Turing machines capture the notion of effective/algorithmic computation.
Differentiate between recursive and recursively enumerable languages.
Recursive vs. Recursively Enumerable Languages
Both are accepted by Turing machines, but differ in the halting guarantee.
- A language is recursive (decidable) if there exists a TM that halts on every input, accepting strings in the language and rejecting those not in it.
- A language is recursively enumerable (RE / semi-decidable) if there exists a TM that halts and accepts every string in the language, but may loop forever on strings not in the language.
| Aspect | Recursive | Recursively Enumerable |
|---|---|---|
| TM behaviour | Always halts (decides) | Halts on accept; may loop on reject |
| Also called | Decidable | Semi-decidable / Turing-recognizable |
| Membership | Decidable | Only "yes" is guaranteed; "no" may not terminate |
| Closure under complement | Closed (recursive) | Not closed |
| Containment | Every recursive language is RE | Not every RE language is recursive |
| Example | , any context-sensitive language | , the Halting Problem language |
Key relation: . A language is recursive iff both and its complement are RE.
Define Mealy and Moore machines and differentiate between them.
Mealy and Moore Machines
Both are finite-state machines with output (finite-state transducers).
Moore machine — output depends only on the current state. Defined as a 6-tuple where associates an output with each state.
Mealy machine — output depends on the current state AND the current input symbol. Defined as a 6-tuple where associates an output with each transition.
Differences
| Aspect | Moore Machine | Mealy Machine |
|---|---|---|
| Output depends on | Current state only | Current state and input symbol |
| Output function | ||
| Output associated with | States (nodes) | Transitions (edges) |
| Output for input of length | symbols (includes initial state output) | symbols |
| Reaction to input | One clock delay (slower) | Immediate (reacts in same cycle) |
| Number of states | Generally needs more states | Generally fewer states |
Both models are equivalent in computational power and can be converted into each other (they compute the same input–output relations, ignoring the initial-state output of Moore).
Explain the closure properties of regular languages.
Closure Properties of Regular Languages
Regular languages are closed under a wide range of operations: applying these operations to regular languages always yields a regular language. Let be regular over alphabet .
- Union: is regular (combine NFAs with a new start state and -moves).
- Concatenation: is regular (link accepting states of the first NFA to the start of the second).
- Kleene star: is regular (loop back accepting states to start).
- Complement: is regular (complete the DFA and swap accepting/non-accepting states).
- Intersection: is regular (product/Cartesian construction of the two DFAs; also via ).
- Set difference: is regular.
- Reversal: is regular (reverse all transitions, swap start and accepting states).
- Homomorphism and inverse homomorphism preserve regularity.
Significance: Because the regular languages form a Boolean algebra (closed under union, intersection, complement), these closure properties let us build and reason about regular languages compositionally and prove non-regularity by closure arguments.
What is the membership problem? Explain the CYK algorithm in brief.
Membership Problem
The membership problem for a grammar/language asks: Given a grammar (or automaton) and a string , does ? i.e. can the grammar generate the string? For context-free grammars this problem is decidable, and the CYK algorithm solves it efficiently.
CYK (Cocke–Younger–Kasami) Algorithm
The CYK algorithm decides membership of a string in a context-free language. The grammar must first be converted to Chomsky Normal Form (CNF) (rules of the form or ).
It uses dynamic programming / bottom-up parsing, filling an upper-triangular table where holds the set of non-terminals that can derive the substring .
CYK(w = a1..an, grammar G in CNF):
for i = 1 to n: # length-1 substrings
V[i][i] = { A : (A -> a_i) in G }
for len = 2 to n: # increasing substring length
for i = 1 to n-len+1:
j = i + len - 1
V[i][j] = {}
for k = i to j-1: # split point
for each rule A -> B C:
if B in V[i][k] and C in V[k+1][j]:
add A to V[i][j]
accept if S (start symbol) in V[1][n]
Result: iff the start symbol .
Time complexity: , where — polynomial, hence the membership problem for CFLs is efficiently decidable.
Construct an NFA for the regular expression (0+1)*1.
NFA for
The regular expression denotes all binary strings that end with the symbol .
NFA :
- States:
- Alphabet:
- Start state:
- Accepting state:
Transition function:
| State | on | on |
|---|---|---|
Diagram (described): State has self-loops on both and (this realizes , allowing any prefix). On reading a , also has a transition to the final state , which is the guess that this is the last symbol. has no outgoing transitions.
Working: The machine stays in consuming any combination of s and s, and nondeterministically moves to the accepting state exactly when the final input symbol is a . Thus it accepts precisely the strings ending in , e.g. , and rejects strings ending in or the empty string.
Explain Rice's theorem in brief.
Rice's Theorem
Statement: Every non-trivial semantic (behavioural) property of the language recognized by a Turing machine is undecidable.
Here:
- A property is a set of recursively enumerable languages (it refers to what the machine computes — i.e. its language — not to how it is coded).
- The property is non-trivial if it is true for some TMs but not all — i.e. is neither the empty set nor the set of all RE languages.
Then the problem "Does have property ?" — formally deciding — is undecidable.
Explanation / Consequences
Rice's theorem generalizes the undecidability of the Halting Problem: we cannot algorithmically test any interesting property of a program's input–output behaviour. The proof reduces the Halting Problem (or ) to deciding the property.
Examples of undecidable questions (by Rice's theorem):
- Is ? (Is the language empty?)
- Is regular / finite / infinite?
- Does accept a particular string ?
- Are two TMs equivalent ()?
Note: The theorem applies only to semantic properties. Syntactic properties (e.g. "does have 5 states?" or "does ever move left?") are about the machine's description and can be decidable.
Define alphabet, string, and language with examples.
Alphabet, String, and Language
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 (length 0). The length is the number of symbols.
- Example: over , the strings , , and are valid; .
- denotes the set of all strings over (including ); .
Language: A set of strings over a given alphabet, i.e. any subset of . A language may be finite or infinite.
- Example over :
- (finite),
- (infinite),
- ,
- (the empty language) and are both valid languages.
Differentiate between DFA and NFA.
DFA vs. NFA
Both are finite automata of the form and accept exactly the regular languages, but they differ in how transitions are defined.
| Aspect | DFA (Deterministic) | NFA (Non-deterministic) |
|---|---|---|
| Transition function | (exactly one next state) | (a set of next states) |
| Next state | Unique for each (state, symbol) | Zero, one, or many possible states |
| (empty) moves | Not allowed | Allowed |
| Acceptance | Single computation path; accept if it ends in | Accept if some path ends in |
| Number of states | Often more states needed | Usually fewer / more compact |
| Construction | Harder to design directly | Easier to design from regular expressions |
| Execution | Faster, deterministic simulation | Needs to track a set of states (or backtrack) |
Equivalence: Every NFA can be converted to an equivalent DFA by the subset (powerset) construction; an NFA with states yields a DFA with at most states. Hence DFA and NFA have the same expressive power — both recognize exactly the class of regular languages.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2078?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2078 (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) 2078 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) 2078 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2078 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.