BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2077 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2077, 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 2077 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Define a Turing Machine formally. Design a Turing Machine that accepts the language L = { a^n b^n c^n | n >= 1 } and explain its working with a transition diagram.
Formal Definition of a Turing Machine
A Turing Machine (TM) is a 7-tuple:
where:
- = finite set of states
- = input alphabet (does not contain the blank )
- = tape alphabet, with and
- = transition function
- = start state
- = blank symbol
- = set of accepting (final) states
A TM reads/writes on an infinite tape and moves its head left () or right (). The language accepted is .
TM for
This is a classic non-context-free language; a single-tape TM accepts it.
Strategy: In each pass, mark the leftmost unmarked as , then move right to mark the leftmost unmarked as , then the leftmost unmarked as . Return to the left and repeat until all symbols are marked. Finally verify nothing is left over.
States: , with the accept state. Tape symbols are markers for matched .
Transition function :
| State | a | b | c | X | Y | Z | B |
|---|---|---|---|---|---|---|---|
| — | — | — | — | — | |||
| — | — | — | — | ||||
| — | — | — | — | ||||
| — | — | ||||||
| — | — | — | — |
Working:
- : replace an by , enter . If it instead sees (all 's already marked) it goes to the verification state .
- : skip remaining 's and already-placed 's, replace the first by , enter .
- : skip remaining 's and 's, replace the first by , move left into .
- : walk left over until the rightmost is found, step right and return to to start the next pass.
- (verification): only 's and 's should remain; on reading blank go to accept state . Any leftover , or causes a halt with no accepting transition (reject).
The machine accepts only strings with equal numbers of , , in the order .
Transition Diagram (description)
Nodes form the marking loop; an arrow from on input goes to , and from on to the double-circle accept state . Self-loops on represent skipping over symbols.
Explain the relationship between regular expressions and finite automata. Show that for every regular expression there is an epsilon-NFA accepting the same language, and convert (a+b)*ab into an equivalent finite automaton.
Regular Expressions and Finite Automata
Regular expressions (RE) and finite automata (FA) are equivalent in expressive power: a language is regular iff it is described by some regular expression, iff it is accepted by some finite automaton (Kleene's Theorem).
- For every FA there exists an equivalent RE (state-elimination / Arden's theorem).
- For every RE there exists an equivalent -NFA (Thompson's construction).
Every RE has an equivalent -NFA (Thompson's Construction)
We prove by structural induction on the RE. Each constructed NFA has exactly one start and one accept state.
Base cases:
- : start and (separate) accept state, no transitions.
- : start accept.
- : start accept.
Inductive cases (let be the NFA for ):
- Union : new start with -moves to the starts of ; their accepts have -moves to a new accept.
- Concatenation : accept of gets an -move to the start of .
- Kleene star : new start start of and new accept; accept of loops back to its start and to the new accept.
By induction, every RE is converted into an -NFA accepting the same language.
Converting to a Finite Automaton
-NFA (Thompson): Build as a loop that reads any number of 's and 's, then concatenate the literals then .
After eliminating -moves and applying the subset construction we obtain a clean DFA. The language is all strings over that end in .
DFA:
| State | on | on |
|---|---|---|
| (start) | ||
| (last symbol was ) | ||
| (just read ) |
- : have not yet seen a pending .
- : last symbol read was (possible prefix of ).
- (accepting): string just ended in .
This DFA accepts exactly .
State the Halting Problem of a Turing Machine. Prove that the Halting Problem is undecidable. Differentiate between decidable and undecidable problems with examples.
The Halting Problem
Statement: Given an arbitrary Turing Machine and an input , determine whether halts (stops) when run on . As a language:
The Halting Problem asks for an algorithm (a TM) that decides membership in for every input.
Proof that the Halting Problem is Undecidable
We use proof by contradiction (diagonalization / reduction).
- Assume a TM exists that decides the halting problem:
always halts and gives the correct answer.
-
Construct a new TM that takes a single TM encoding as input and does:
- Run on (i.e., does halt on its own description?).
- If says "halts" loops forever.
- If says "loops" halts.
-
Now run on its own description :
- If halts on , then by construction said "loops," so should loop — contradiction.
- If loops on , then said "halts," so should halt — contradiction.
Both cases are contradictory, so the assumption that exists is false. Hence no TM can decide the Halting Problem; it is undecidable.
Decidable vs Undecidable Problems
| Aspect | Decidable | Undecidable |
|---|---|---|
| Definition | A TM (decider) exists that always halts with yes/no | No TM halts with the correct answer on all inputs |
| Language class | Recursive | Not recursive |
| Termination | Always halts | May loop forever on some inputs |
| Examples | Membership in a regular/CFL; emptiness of a DFA; "does DFA accept "; membership | Halting problem; Post Correspondence Problem; "is " for a TM; Rice's theorem properties |
Note: A problem can be recursively enumerable (a TM accepts all yes-instances but may loop on no-instances) yet still undecidable — the Halting Problem is exactly such a case.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Explain the conversion of a CFG into Greibach Normal Form (GNF).
Greibach Normal Form (GNF)
A CFG is in GNF if every production has the form:
where is a single terminal and is a (possibly empty) string of variables (). Each production starts with exactly one terminal followed by zero or more non-terminals.
Conversion Procedure
- Pre-process: Eliminate -productions, unit productions, and useless symbols, then convert the grammar to Chomsky Normal Form (CNF) as a starting point.
- Order the variables .
- Remove left recursion and forward substitution: Rewrite productions so that for every , we have .
- If with , substitute all productions of into .
- If (left recursion), eliminate it by introducing a new variable :
- Make leading symbols terminal: Starting from the highest-numbered variable (whose productions already begin with a terminal), back-substitute downward so that every production begins with a terminal.
- Fix the new variables the same way so their productions also begin with terminals.
Example
For (left-recursive):
- Eliminate left recursion: , .
- Both productions now begin with a terminal — this is in GNF.
Use: GNF guarantees each derivation step consumes exactly one terminal, which is useful for constructing a PDA and for proving that every CFL has a PDA (and bounds derivation length to steps).
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 captures the complete configuration of the PDA at a moment in time. It is a triple:
where:
- = current state,
- = remaining (unread) portion of the input,
- = current contents of the stack (top written leftmost).
A single move is written using the turnstile : if contains , then
The reflexive-transitive closure denotes zero or more moves.
Acceptance by Final State
The PDA accepts if, starting from the initial ID, it can consume all of and reach a final state (stack contents irrelevant):
Acceptance by Empty Stack
The PDA accepts if, after consuming all of , the stack becomes empty (final state irrelevant):
Equivalence
Both modes accept exactly the context-free languages. For any PDA accepting by final state there is an equivalent PDA accepting by empty stack, and vice versa, so the two acceptance criteria are equivalent in power.
Explain the working of a multi-tape Turing Machine.
Multi-tape Turing Machine
A multi-tape TM has tapes (), each with its own independent read/write head. It is defined like a standard TM except the transition function is:
Working
- Input: The input is placed on tape 1; the other tapes start blank.
- Reading: In one step the machine reads the symbols under all heads simultaneously (one symbol per tape).
- Action: Based on the current state and the -tuple of scanned symbols, it:
- changes state,
- writes a new symbol on each tape, and
- moves each head independently left (), right (), or keeps it stationary ().
- Tapes are used as scratch/work space (e.g., one tape for input, one for a counter, one for output), which makes algorithms much easier to design.
Equivalence with a Single-Tape TM
A multi-tape TM is no more powerful than a single-tape TM; both accept exactly the recursively enumerable languages.
- A single-tape TM can simulate a -tape TM by storing the tapes on one tape using tracks, marking each head position, and sweeping across to gather symbols.
- Cost: If a -tape TM runs in time , the single-tape simulation runs in time.
Thus multi-tape TMs improve convenience and efficiency, not computational power.
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. It takes as input an encoding of an arbitrary TM together with an input string , i.e. the pair , and then simulates running on :
accepts iff accepts , halts iff halts, and loops iff loops.
How it Works
typically uses multiple tracks/tapes to store: (1) the encoded transition table of , (2) the current tape contents of , and (3) the current state of . It repeatedly looks up the matching transition of in the description, updates the simulated tape, state and head position, and continues until halts.
Significance
- Stored-program concept: A UTM is the theoretical basis of the modern general-purpose, programmable computer — program and data are both stored as input. This directly inspired the von Neumann architecture.
- Universality: It shows one fixed machine can compute anything any TM can compute, supporting the Church–Turing thesis.
- Undecidability: The existence of the UTM enables key undecidability proofs, since its acceptance language is recursively enumerable but not recursive (undecidable), central to proving the Halting Problem undecidable.
Differentiate between recursive and recursively enumerable languages.
Recursive vs Recursively Enumerable Languages
Both are defined by Turing machines, but differ in halting behaviour.
- Recursive language (Decidable): A language is recursive if there exists a TM (a decider) that always halts — it accepts every and rejects (halts) every .
- Recursively Enumerable (RE) language (Turing-recognizable): A language is RE if there exists a TM that accepts every , but on it may either reject or loop forever.
| Property | Recursive | Recursively Enumerable |
|---|---|---|
| TM behaviour | Always halts (decider) | Halts on accept; may loop on reject |
| Decidability | Decidable | May be undecidable |
| Membership | Always answerable (yes/no) | "Yes" answerable; "no" may never come |
| Closure under complement | Closed (complement also recursive) | NOT closed under complement |
| Relationship | Every recursive language is RE | Not every RE language is recursive |
| Example | , any decidable problem | (universal language), the Halting language |
Key theorem: is recursive iff both and its complement are recursively enumerable. The Halting language is RE but not recursive, proving recursive RE.
Define Mealy and Moore machines and differentiate between them.
Mealy and Moore Machines
Both are finite-state machines with output (transducers). A general definition is the 6-tuple , where is the output alphabet and is the output function — the two differ in .
Moore Machine
Output depends only on the current state:
Each state is labelled with an output symbol. For an input of length , the output length is (the start state's output is emitted before any input).
Mealy Machine
Output depends on both the current state and the current input:
Outputs are written on the transitions. For an input of length , the output length is .
Differences
| Aspect | Moore Machine | Mealy Machine |
|---|---|---|
| Output depends on | Current state only | Current state and current input |
| Output associated with | States (nodes) | Transitions (edges) |
| Output function | ||
| Output length (input len ) | ||
| Reaction to input | Delayed by one clock | Immediate |
| Number of states | Often more | Often fewer |
Both machines are equivalent in computational power — any Moore machine can be converted to an equivalent Mealy machine and vice versa.
Explain the closure properties of regular languages.
Closure Properties of Regular Languages
A class of languages is closed under an operation if applying that operation to regular languages always yields a regular language. Regular languages are closed under all the following operations. Let be regular.
- Union — is regular. (RE: ; or product/parallel NFA.)
- Concatenation — is regular. (RE: .)
- Kleene Star — is regular. (RE: .)
- Complementation — is regular. (Take the DFA and swap accepting/non-accepting states.)
- Intersection — is regular. (Product automaton; or via by De Morgan.)
- Difference — is regular.
- Reversal — is regular. (Reverse all transitions, swap start/final states.)
- Homomorphism and inverse homomorphism — regular languages are closed under both.
Significance: These properties let us prove a language regular by building it from known regular languages, and the decision/closure under intersection & complement is heavily used (e.g., for the product construction and for proving non-regularity by combining with the pumping lemma).
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 , does ? For context-free grammars this is decidable — the CYK algorithm answers it in polynomial time.
CYK (Cocke–Younger–Kasami) Algorithm
CYK is a bottom-up dynamic-programming parser that decides whether , where must be in Chomsky Normal Form (productions of the form or ). For it builds a triangular table = the set of variables that derive the substring of length starting at position .
Steps:
- Length-1: For each symbol , set .
- Longer substrings: For length and start , examine every split point ():
- Acceptance: iff the start symbol (the cell covering the whole string).
Complexity: time, space — polynomial, so the membership problem for CFLs is decidable.
for i = 1 to n: // base case
V[i][1] = { A : A -> a_i }
for j = 2 to n: // substring length
for i = 1 to n-j+1: // start position
for k = 1 to j-1: // split point
if A->BC, B in V[i][k], C in V[i+k][j-k]:
add A to V[i][j]
accept if S in V[1][n]
Construct an NFA for the regular expression (0+1)*1.
NFA for
The regular expression describes all strings over that end with .
NFA :
- is the start state. On both and it can stay in (the loop), and on it may also non-deterministically move to .
- is the single accepting state, reached only after reading a final .
Transition table:
| State | on | on |
|---|---|---|
Transition diagram (description): A self-loop on labelled (for ); an arrow ; is a double circle (accepting) with no outgoing edges.
Verification: A string is accepted iff there is a path ending in , i.e. iff the last symbol read was — exactly . For example, 101 is accepted, 110 is rejected.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2077?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2077 (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) 2077 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) 2077 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2077 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.