BSc CSIT (TU) Science Theory of Computation (BSc CSIT, CSC257) Question Paper 2075 Nepal
This is the official BSc CSIT (TU) (Science stream) Theory of Computation (BSc CSIT, CSC257) question paper for 2075, 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 2075 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
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 context-free grammar is a 4-tuple where:
- = finite set of variables (non-terminals)
- = finite set of terminals, with
- = finite set of productions of the form , where and
- = the start symbol
It is context-free because the left side of every production is a single variable, so a variable can be replaced regardless of context.
Converting to Chomsky Normal Form (CNF)
A grammar is in CNF if every production has the form (two variables) or (single terminal). Given grammar:
Step 1 — Add a new start symbol. Introduce so the start symbol never appears on a right side.
Step 2 — Remove -productions. Nullable variables: (from ), and (since ). Remove and add all combinations omitting nullable symbols:
- gives (dropping one or both 's).
- gives .
- stays; nothing new since has a non-empty body.
Resulting set:
Step 3 — Remove unit productions. Units are . Drop (trivial). Substitute the bodies:
- (from ) and (from )
Step 4 — Replace terminals in long bodies. Introduce and replace in by , giving bodies .
Step 5 — Break bodies longer than 2. For , introduce , so .
Final CNF Grammar
Every production now has the form or , so the grammar is in Chomsky Normal Form and generates the same language as the original.
What is a Pushdown Automaton (PDA)? Design a PDA that accepts the language L = { a^n b^n | n >= 1 } and trace its moves for the string 'aabb'.
Pushdown Automaton (PDA)
A Pushdown Automaton is a finite automaton augmented with an auxiliary stack (LIFO) memory, which gives it more power than a finite automaton and lets it recognize context-free languages. Formally it is a 7-tuple:
- = finite set of states
- = input alphabet
- = stack alphabet
- finite subsets of = transition function
- = start state, = initial stack symbol, = accepting states
PDA for
Idea: push a marker for each , then pop one for each ; accept when input ends and the stack is back to its bottom.
Let (acceptance by final state). Transitions:
| # | Meaning | |
|---|---|---|
| 1 | push first | |
| 2 | push more 's | |
| 3 | first : pop | |
| 4 | pop per | |
| 5 | stack empty of 's, accept |
Trace for the string aabb
ID notation: , stack top on the left.
The input is fully consumed and the machine is in accepting state , so aabb is accepted. Hence accepts .
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:
- = finite set of states
- = input alphabet (does not contain the blank)
- = tape alphabet, , with blank
- = transition function (write a symbol, move head Left or Right)
- = start state, = blank symbol, = accepting (halting) states
TM for
Strategy: repeatedly mark the leftmost unmarked as , the leftmost as , the leftmost as , then return to the left and repeat. This matches one , one , one per pass, guaranteeing equal counts in correct order. Accept when only remain.
States: (find ), (scan right for ), (scan right for ), (return left), (verify all marked), .
| State | Read | Write | Move | Next | Action |
|---|---|---|---|---|---|
| R | mark an | ||||
| R | no left, verify | ||||
| same | R | skip to a | |||
| R | mark a | ||||
| same | R | skip to a | |||
| L | mark a | ||||
| same | L | move left | |||
| R | back at start, repeat | ||||
| same | R | ensure no remain | |||
| R | accept |
If at any point the expected symbol is missing (e.g. a before all 's are matched, or leftover ), no transition applies and the machine halts and rejects.
Transition Diagram (described)
Nodes form a loop: each cycle converts one , one , one . The arc (taken when the first remaining symbol is and the rest are only ) leads to the accepting state. Self-loops on skip over already-marked or not-yet-needed symbols.
Working on aabbcc
Pass 1: — first marked. Pass 2: remaining marked as . Tape becomes ; in the head scans only then a blank, reaching . Thus the string is accepted.
Because this TM both writes and reads and may visit a cell many times, it recognizes the context-sensitive / recursively enumerable language , which is not context-free.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Write a regular expression for strings over {0,1} that contain at least one '0' and at least one '1'.
We need strings over containing at least one 0 and at least one 1. A clean regular expression is:
The first term covers strings where some 0 appears before some 1; the second covers strings where a 1 appears before a 0. Their union therefore guarantees the presence of both symbols.
(Equivalently, in extended notation: all strings except those with no 0 or no 1, i.e. .)
State Arden's theorem and explain its use in obtaining a regular expression from a finite automaton.
Arden's Theorem
Statement: Let and be two regular expressions over an alphabet . If does not contain the empty string (i.e. ), then the equation
has a unique solution:
Use in Obtaining a Regular Expression from a Finite Automaton
For a finite automaton, write one equation per state describing the strings that reach that state. For each state , its equation is the sum, over all incoming transitions, of (source-state expression input symbol); the start state's equation also includes .
This yields a system of simultaneous equations of the form . Using Arden's theorem, we repeatedly substitute and solve each self-referential equation by replacing with , eliminating variables one by one. The expression finally obtained for the final (accepting) state is the regular expression denoting the language accepted by the automaton.
Why the condition matters: it ensures uniqueness; if contained , infinitely many solutions would satisfy the equation.
What is an ambiguous grammar? Show with an example that a grammar is ambiguous.
Ambiguous Grammar
A context-free grammar is said to be ambiguous if there exists at least one string that has two or more distinct derivation trees (equivalently, two distinct leftmost or two distinct rightmost derivations). Ambiguity is a property of the grammar, not of the language.
Example
Consider the expression grammar:
Take the string . It has two different leftmost derivations / parse trees:
Parse 1 (treats as the top operator):
Parse 2 (treats as the top operator):
Since the same string admits two distinct parse trees (one grouping as , the other as ), the grammar is ambiguous.
Eliminate left recursion from the grammar A -> Aa | b.
Eliminating Left Recursion from
The production is immediately left-recursive (the variable appears as the leftmost symbol of its own body).
General rule: a rule of the form
(where does not start with ) is rewritten using a new variable as:
Applying it here with and :
This grammar is right-recursive and generates exactly the same language (i.e. followed by zero or more 's), but is now suitable for top-down (e.g. recursive-descent / LL) parsing.
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. Thus every body begins with exactly one terminal followed only by non-terminals.
Conversion Procedure (CFG → GNF)
Pre-requisite: first convert the grammar to Chomsky Normal Form and remove -productions, unit productions, and useless symbols.
Step 1 — Order the variables. Rename the variables .
Step 2 — Make productions increasing in index. Modify productions so that every rule has :
- If , substitute every production of into the body of , then repeat.
- If , it is left recursion; eliminate it using a new variable :
(where ).
Step 3 — Make leading symbols terminals (back-substitution). Now 's bodies already start with a terminal. Working backwards from to , substitute the (already-GNF) productions of into any rule whose body starts with , so that every leading symbol becomes a terminal.
Step 4 — Fix the new variables . Apply the same back-substitution to the introduced variables so their bodies also begin with a terminal.
The result is an equivalent grammar in GNF. GNF is important because it guarantees each derivation step consumes exactly one input terminal, which directly yields an equivalent PDA and bounds derivation length to steps for a string .
Define instantaneous description (ID) of a PDA and explain acceptance by final state and by empty stack.
Instantaneous Description (ID) of a PDA
An instantaneous description captures the complete momentary configuration of a PDA. It is a triple:
- = the current state
- = the remaining unread input string
- = the current stack contents (conventionally written with the top of the stack on the left)
A single move is written with the turnstile relation : if contains , then
denotes zero or more moves.
Acceptance by Final State
Starting from , the PDA accepts by final state if there is a sequence of moves leading to an accepting state, regardless of the stack contents:
i.e. the whole input is consumed and the machine ends in some final state .
Acceptance by Empty Stack
The PDA accepts by empty stack if, after consuming all input, the stack becomes completely empty (the set is irrelevant here):
Equivalence: the two acceptance modes define the same class of languages (the context-free languages); any PDA accepting by final state can be converted to one accepting by empty stack and vice versa.
Explain the working of a multi-tape Turing Machine.
Multi-Tape Turing Machine
A multi-tape Turing Machine has tapes, each with its own independent read/write head. The machine reads the symbols under all heads simultaneously and, in one move, can write a new symbol on each tape and move each head independently Left, Right, or stay (S).
Working / Transition Function
For a -tape machine the transition function is
On a single step the control unit, based on the current state and the scanned symbols , does the following at once:
- Moves to a new state,
- Writes a symbol on each of the tapes,
- Moves each of the heads independently.
Initially the input is placed on tape 1 and the other tapes hold blanks; the extra tapes serve as scratch / working memory, which often makes algorithms much simpler to express (e.g. copying, counting, or comparing substrings).
Power
A multi-tape TM is no more powerful than a standard single-tape TM: any -tape TM can be simulated by a single-tape TM (storing the tapes interleaved on one tape with head-position markers). The simulation costs at most a quadratic slowdown ( steps to simulate steps), so the class of languages recognized (recursively enumerable) is identical. Multi-tape machines are mainly a convenience that simplifies design and improves time efficiency.
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 an arbitrary TM together with an encoded input string , written as , and then:
- simulates the computation of on step by step, and
- accepts/halts exactly when would accept/halt on (and loops if loops).
Formally, on produces the same result that produces on . keeps three pieces of information on its tape: the encoded description of , the simulated tape contents of , and 's current state.
Significance
- Stored-program concept: the UTM shows that a single fixed machine can run any algorithm if the program (the description of ) is supplied as data. This is the theoretical foundation of the modern general-purpose, stored-program computer (von Neumann architecture).
- Existence of a universal model: it proves computation is programmable — one machine, many tasks — rather than needing a new machine per problem.
- Undecidability: the UTM is central to proving the Halting Problem undecidable; the universal/diagonal construction shows there is no algorithm to decide whether an arbitrary halts on .
- It establishes the notion of a recursively enumerable universal language , which is RE but not recursive.
Differentiate between recursive and recursively enumerable languages.
Recursive vs Recursively Enumerable Languages
Both classes are defined in terms of Turing Machines, but differ in whether the TM is guaranteed to halt.
| Aspect | Recursive (Decidable) | Recursively Enumerable (RE) |
|---|---|---|
| TM behaviour | A TM always halts on every input — it halts and accepts strings in , and halts and rejects strings not in . | A TM halts and accepts strings in , but may run forever (loop) on strings not in . |
| Decidability | The language is decidable; membership can always be decided. | The language is only semi-decidable (recognizable); membership can be confirmed but non-membership may never be confirmed. |
| Also called | Decidable / Turing-decidable. | Turing-recognizable / Type-0. |
| Closure under complement | Closed — if is recursive, so is . | Not closed under complement in general. |
| Relationship | Every recursive language is RE. | RE is a strict superset: there exist RE languages that are not recursive (e.g. the universal language , the Halting language). |
Key theorem: is recursive iff both and its complement are recursively enumerable.
Example: is recursive (decidable). The Halting Problem language is recursively enumerable but not recursive.
Frequently asked questions
- Where can I find the BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) question paper 2075?
- The full BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2075 (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) 2075 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) 2075 paper?
- The BSc CSIT (TU) Theory of Computation (BSc CSIT, CSC257) 2075 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.