Chapter 2
Mathematical Foundation for Computer Science
PU BCA past exam questions
Past questions and answers
57 questions set from this chapter, 3 of them more than once. Most repeated first.
- Asked 2 times
- 2025 Spring · 8 marks
- 2024 Fall · 8 marks
Define planar and Euler Graph. A connected planar graph has nine vertices having degrees 2, 2, 2, 3, 3, 3, 4, 4 and 5. How many edges and faces are there?
Answer
Planar graph. A graph is planar if it can be drawn in the plane so that no two edges cross except at their end vertices. Such a drawing divides the plane into regions called faces.
Euler graph. A connected graph is an Euler graph if it has an Euler circuit, that is, a closed walk that uses every edge exactly once. A connected graph is Eulerian if and only if every vertex has even degree.
Numerical part. The degrees are and .
Sum of degrees:
By the handshaking theorem, , so
By Euler's formula for a connected planar graph, :
Number of edges = 14 and number of faces = 7.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- Asked 2 times
- 2025 Spring · 7 marks
- 2023 Spring · 8 marks
Solve the recurrence relation for and , .
Answer
Characteristic equation:
General solution:
Using the initial conditions:
- .
- .
Solution:
Check: .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- Asked 2 times
- 2024 Fall · 5 marks
- 2023 Spring · 5 marks
Write short notes on: Hamilton Graph
Answer
Hamiltonian path and circuit. A Hamiltonian path in a graph is a simple path that visits every vertex exactly once. A Hamiltonian circuit (cycle) is a simple cycle that passes through every vertex exactly once and returns to the starting vertex. A graph that has a Hamiltonian circuit is called a Hamilton (Hamiltonian) graph. The idea is named after Sir William Rowan Hamilton, who introduced it through the "icosian game".
Examples. The cycle , the complete graph () and the cube are Hamiltonian. The complete bipartite graph is not.
Sufficient conditions (a graph with vertices):
- Dirac's theorem: if for every vertex , the graph is Hamiltonian.
- Ore's theorem: if for every pair of non-adjacent vertices , the graph is Hamiltonian.
Necessary conditions: every vertex must have degree at least 2, and the graph must be connected with no cut vertex. If a vertex of degree 2 exists, both its edges must be in the circuit.
Comparison with Euler circuit. An Euler circuit uses every edge once and has a simple degree test (all degrees even). For a Hamiltonian circuit, which uses every vertex once, no simple necessary and sufficient test is known; deciding it is NP-complete.
Application: the travelling salesman problem asks for the cheapest Hamiltonian circuit in a weighted graph.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 8 marks
Find the solution of the recurrence relation: ; with initial condition , .
Similar questions: Recurrence an - 6a(n-1) + 8a(n-2) = 3 (2024 Fall)
Answer
Homogeneous part. , so and
Particular solution. Since is not a characteristic root, try . Substituting:
Divide by :
General solution:
Initial conditions:
- : .
- : .
Subtracting twice the first equation from the second: , so .
Solution:
Check: . ✓
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 7 marks
What do you mean by DFA? Design a DFA for the language
Similar questions: DFA for strings ending with bb (2024 Fall)
Answer
DFA. A Deterministic Finite Automaton is a 5-tuple where is a finite set of states, the input alphabet, the transition function (exactly one next state for every state and symbol), the start state, and the set of accepting (final) states.
DFA for .
States: , start state , final state , a dead (trap) state.
| State | on | on |
|---|---|---|
| (read ) | ||
| (read ) | ||
| (read ) | ||
Working: ; once has been read the machine stays in whatever follows. Any other beginning (for example , , ) goes to the dead state, which is never accepted.
Example: ends in (accepted); ends in (rejected).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 8 marks
Find the solution of the recurrence relation: ; with initial condition ,
Similar questions: Recurrence with 42.4^n (2025 Spring)
Answer
Homogeneous part. , so
Particular solution. The right-hand side is a constant and is not a characteristic root, so try :
General solution:
Initial conditions:
- : .
- : .
Subtracting: , then .
Solution:
Check: and . ✓
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 8 marks
What do you mean by DFA? Design a DFA for the language
Similar questions: DFA for strings starting with abb (2025 Spring)
Answer
DFA. A Deterministic Finite Automaton is a 5-tuple : a finite set of states, the input alphabet, the transition function (exactly one move for each state and symbol), the start state and the set of final (accepting) states. A string is accepted if the DFA is in a final state after reading it completely.
DFA for .
States: (start; the last symbol is not , or nothing read), (the string ends in exactly one ), (the string ends in ; the final state).
| State | on | on |
|---|---|---|
Formally, , , .
Working: an always breaks a run of s and returns to ; one moves ; a second consecutive moves ; further s keep the machine in .
Example: goes (accepted); goes back to (rejected); ends in (rejected).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
How regular expression is converted into DFA? Explain it with suitable example.
Similar questions: Regular expression, applications, DFA to regex (2023 Spring)
Answer
A regular expression (RE) is converted to a DFA in two stages: RE -NFA (Thompson's construction), then -NFA DFA (subset construction).
Step 1: RE to -NFA (Thompson's construction). Build small NFAs for the basic parts and combine them:
- Symbol : two states . The empty string : .
- Union : a new start state with -moves to the starts of both NFAs, and -moves from both finals to a new final state.
- Concatenation : an -move from the final state of to the start state of .
- Closure : a new start and final state, with -moves start start of , final of final of -NFA's new final, final of start of (repeat), and start new final (zero repetitions).
Step 2: -NFA to DFA (subset construction).
- Compute the -closure of the NFA start state; this is the DFA start state.
- For each DFA state (a set of NFA states) and each input symbol , compute ; this set is a DFA state.
- Repeat until no new sets appear.
- Any DFA state that contains an NFA final state is a final state.
Example: . Thompson's construction gives an -NFA; after removing the -moves it reduces to the following NFA:
NFA: ; ; , final state .
Subset construction:
| DFA state | on | on |
|---|---|---|
| (dead) | ||
Start state , final state . The resulting DFA accepts exactly the strings that start with and end with , which is the language of . If needed, the DFA can be minimised by merging equivalent states.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
What is regular expression? List and explain its application. Explain how DFA is converted into regular expression?
Similar questions: Converting regular expression to DFA (2024 Spring)
Answer
Regular expression (RE). A regular expression is an algebraic notation describing a regular language, built from symbols of , and using union ( or ), concatenation, and Kleene closure (). For example, describes all strings over ending in .
Applications.
- Lexical analysis: compilers use REs to define tokens (identifiers, numbers, keywords), which are converted into DFAs by tools such as Lex/Flex.
- Pattern matching and search:
grep,sed, text editors and IDEs find and replace text patterns. - Input validation: checking email addresses, phone numbers, passwords and dates in forms.
- Data extraction and web scraping: pulling structured fields from logs and documents.
- Network and security tools: intrusion detection and packet filtering match patterns in traffic.
- Specification of protocols and hardware: describing the language accepted by simple controllers and finite-state machines.
Converting a DFA to a regular expression (state elimination method).
- Add a new start state with an -edge to the old start state, and a new single final state with -edges from every old final state.
- Label every edge with an RE (merge parallel edges with ).
- Eliminate the remaining states one at a time. To remove state , for every pair of states and with edges , , and a self-loop , add the edge (union it with any existing edge).
- When only the new start and final states remain, the label on the edge between them is the RE of the DFA.
Example. DFA with states (start), (final): , , , . Eliminating (loop , in-edge , out-edge to ) gives a loop on labelled , and the path to the final state is . Hence
which is equivalent to : all strings ending in .
Another method is Arden's theorem: write state equations (for the start) and solve using .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 7 marks
What is graph theory? Explain the application of graph theory in computer science.
Answer
Graph theory is the branch of mathematics that studies graphs. A graph consists of a non-empty set of vertices (nodes) and a set of edges joining pairs of vertices. Graphs model pairwise relations between objects, and graph theory studies their properties such as paths, cycles, connectivity, colouring, trees and planarity.
Applications in computer science:
- Computer networks. Computers or routers are vertices and links are edges. Shortest-path algorithms (Dijkstra, Bellman-Ford) are used for routing, and spanning trees (Prim, Kruskal) for cheap network design and loop-free switching.
- World Wide Web and search engines. Web pages are vertices and hyperlinks are directed edges. Crawlers traverse this graph by BFS/DFS, and PageRank ranks pages using the link structure.
- Social networks. People are vertices and friendships are edges. Graph algorithms find communities, influencers and friend suggestions.
- Compiler design and operating systems. Control-flow graphs and data-flow graphs are used in optimisation. Register allocation is done by graph colouring. Directed graphs of resource allocation are used to detect deadlock (cycles).
- Databases and data structures. Trees, heaps and tries are special graphs. Entity relationships and dependency graphs are modelled with graphs.
- Scheduling and resource allocation. Graph colouring is used for timetabling and frequency assignment, and topological sorting for ordering tasks with dependencies.
- Artificial intelligence. State-space search (BFS, DFS, A*), decision trees and Bayesian networks use graphs.
- Circuit design (VLSI). Planar graphs are used to lay out circuits without crossing wires.
- Software engineering. Call graphs, module dependency graphs and finite-state machines.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 7 marks
Write Dijkestra's Algorithm. Use Dijkestra's Algorithm to find the length of the shortest path from vertex A to E. (Weighted graph given in the paper.)
Answer
Dijkstra's algorithm finds the shortest path from a source vertex to all other vertices in a weighted graph with non-negative edge weights.
- Set and for every other vertex. Let (the set of finished vertices).
- Pick the vertex with the smallest and add it to .
- For every neighbour of with : if , set and record as the predecessor of .
- Repeat steps 2 and 3 until the destination is in (or all vertices are in ).
- Trace the predecessors back from the destination to get the path.
Worked example. Consider the weighted graph with edges , , , , , , .
| Step | Vertex fixed | A | B | C | D | E |
|---|---|---|---|---|---|---|
| 0 | 0 | |||||
| 1 | A (0) | 0 | 4 | 2 | ||
| 2 | C (2) | 0 | 3 | 2 | 10 | 12 |
| 3 | B (3) | 0 | 3 | 2 | 8 | 12 |
| 4 | D (8) | 0 | 3 | 2 | 8 | 10 |
| 5 | E (10) | 0 | 3 | 2 | 8 | 10 |
Shortest path: , with length .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 8 marks
Differentiate between Hamiltonian circuit and Euler circuit. Give an example of graph with 5 vertices which is Hamiltonian but not eulerian.
Answer
| Basis | Euler circuit | Hamiltonian circuit |
|---|---|---|
| Definition | A closed walk that uses every edge exactly once | A cycle that visits every vertex exactly once (returning to the start) |
| Repeats | Vertices may repeat; edges may not | Neither vertices nor edges repeat (except the start/end vertex) |
| Condition | Exists iff the graph is connected and every vertex has even degree | No simple necessary and sufficient condition is known |
| Sufficient tests | The degree test above is exact | Dirac: for all (with ); Ore: for non-adjacent |
| Difficulty | Easy to test | NP-complete to decide |
| Named after | Leonhard Euler (Königsberg bridges) | W. R. Hamilton (icosian game) |
Example: Hamiltonian but not Eulerian (5 vertices). Take the 5-cycle and add the chord .
- Hamiltonian: visits all five vertices once.
- Not Eulerian: and are odd, so no Euler circuit exists.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 7 marks
Define Tautology, Contradiction and Logical Equivalence. Prove that implication and its contraposition are logically equivalent.
Answer
Tautology. A compound proposition that is true for every assignment of truth values to its variables, for example .
Contradiction. A compound proposition that is false for every assignment of truth values, for example .
Logical equivalence. Two propositions and are logically equivalent, written , if is a tautology, i.e. they have the same truth value in every row of the truth table.
Claim. .
| T | T | F | F | T | T |
| T | F | F | T | F | F |
| F | T | T | F | T | T |
| F | F | T | T | T | T |
The last two columns are identical in every row, so : an implication and its contrapositive are logically equivalent.
Algebraic check. .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 8 marks
State the principle of mathematical induction. Using mathematical induction, prove that: for all .
Answer
Principle of mathematical induction. Let be a statement about the integer . If
- Basis step: is true, and
- Inductive step: for every , ,
then is true for all integers .
Proof. Let : .
Basis step (). LHS and RHS . So is true.
Inductive step. Assume is true for some :
Add the next term to both sides:
This is exactly . Hence .
By the principle of mathematical induction, for all .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 7 marks
Verify following argument is valid using the rules of inference: If it rains, then the ground will be wet. If it does not rain, then the picnic will be held. If the picnic is held, then I will have a good time. Therefore, if the ground is not wet, then I will have a good time.
Answer
Let : it rains; : the ground is wet; : the picnic is held; : I have a good time.
Premises: , , .
Conclusion: .
| Step | Statement | Reason |
|---|---|---|
| 1 | Premise | |
| 2 | Contrapositive of 1 | |
| 3 | Premise | |
| 4 | Hypothetical syllogism (2, 3) | |
| 5 | Premise | |
| 6 | Hypothetical syllogism (4, 5) |
The conclusion follows from the premises by valid rules of inference, so the argument is valid.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 8 marks
Differentiate between Direct and Indirect proof. Prove that is an irrational number.
Answer
Difference between direct and indirect proof
| Direct proof | Indirect proof |
|---|---|
| To prove , assume is true and deduce through a chain of valid steps. | To prove , do not argue from to directly. |
| Starts from the hypothesis and moves straight to the conclusion. | Either (a) contrapositive: assume and prove ; or (b) contradiction: assume and derive a contradiction. |
| Used when the path from to is obvious. | Used when the direct route is hard, or when the conclusion is a negative statement such as "is irrational". |
| Example: if is even, then is even. | Example: is irrational. |
Theorem. is irrational.
Proof (by contradiction). Suppose is rational. Then with integers , , and have no common factor (the fraction is in lowest terms).
Squaring gives , so
Thus is even, which means is even (if were odd, would be odd). Write . Then
So is even, and hence is even.
Now both and are even, so they have the common factor . This contradicts the assumption that is in lowest terms.
Therefore the assumption is false, and is irrational.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 8 marks
Explain the concept of Finite State Machine with examples.
Answer
Finite State Machine (FSM). A finite state machine is an abstract model of computation with a finite number of states. At any time it is in exactly one state, and it moves from state to state on input symbols according to a transition function. It is used to model digital circuits, protocols, lexical analysers and control systems.
Types:
- FSM with output (Mealy/Moore machine). : states, input alphabet, output alphabet, the next-state function, the output function (depending on state and input for Mealy, on state only for Moore), and the initial state.
- FSM without output (finite automaton, DFA/NFA). with a set of final states. It accepts a string if it ends in a final state. The accepted strings form a regular language.
Example 1 (Mealy machine: parity / unit delay). A machine with states that outputs when the input bit differs from the previous one.
| State | Input 0 | Input 1 |
|---|---|---|
| , out 0 | , out 1 | |
| , out 1 | , out 0 |
For input from , the output is .
Example 2 (DFA). A DFA accepting binary strings with an even number of 1s: states (start and final) and ; on stay in the same state, on switch between and .
Example 3 (vending machine). States record the amount inserted (0, 5, 10); inputs are coins; the output is "release item" once the total reaches 15.
An FSM is drawn as a state diagram (circles for states, labelled arrows for transitions) or written as a state table.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 5 marks
Write short notes on: Grammar
Answer
Grammar. A formal grammar describes how to generate the strings of a language. It is defined as a 4-tuple
- : finite set of variables (non-terminals).
- : finite set of terminals (the alphabet of the language), with .
- : finite set of production rules of the form .
- : the start symbol.
The language generated is , the set of terminal strings derivable from .
Example. with generates . A derivation is .
Chomsky hierarchy:
| Type | Grammar | Productions | Accepted by |
|---|---|---|---|
| 0 | Unrestricted (phrase structure) | Turing machine | |
| 1 | Context-sensitive | with | Linear bounded automaton |
| 2 | Context-free | Pushdown automaton | |
| 3 | Regular | or | Finite automaton |
Each type is a proper subset of the one above it. Grammars are used to define programming-language syntax and in compiler design.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 5 marks
Write short notes on: Predicate and Quantifiers
Answer
Predicate. A predicate is a statement containing one or more variables that becomes a proposition when values are assigned to the variables, for example : "". is true and is false. The set of values allowed for is the domain (universe of discourse).
Quantifiers. Quantifiers state for how many values of the variable the predicate holds.
- Universal quantifier ("for all"). is true if is true for every in the domain, and false if there is at least one counterexample.
- Existential quantifier ("there exists"). is true if is true for at least one in the domain, and false if is false for every .
Negation (generalised De Morgan laws):
Examples. Domain: real numbers. is true. is true. is false.
Translation. "All students are clever" is ; "Some student is clever" is .
Quantified predicates are the basis of predicate logic, used in specifications, databases (SQL) and automated reasoning.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2025 Spring · 5 marks
Write short notes on: Path matrix
Answer
Path matrix (reachability matrix). For a directed graph with vertices , the path matrix is the Boolean matrix with
It tells which vertices can be reached from which, whatever the path length.
Computing from the adjacency matrix . A path in an -vertex graph has length at most , so
and if the entry , else . Equivalently, using Boolean matrix products.
Warshall's algorithm computes it more efficiently. Start with and for set
The final matrix is the path matrix. It takes time.
Uses. Testing whether a graph is strongly connected (all entries of are 1), finding the transitive closure of a relation, and detecting cycles (some ).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 7 marks
Define pseudograph, directed graph, wheel and tree with example. Show that for n vertices for a complete graph the number of edges is .
Answer
Pseudograph. A graph in which both multiple edges (parallel edges) and loops (an edge joining a vertex to itself) are allowed. Example: vertices with two edges between and and a loop at .
Directed graph (digraph). A graph in which each edge is an ordered pair of vertices, drawn as an arrow from (initial vertex) to (terminal vertex). Example: , is a directed triangle.
Wheel . Take the cycle and add one new vertex (the hub) joined to every vertex of the cycle. Example: has 5 vertices (a 4-cycle plus a hub) and edges.
Tree. A connected undirected graph with no cycles. A tree with vertices has exactly edges, and there is a unique path between any two vertices. Example: a path , or a star with one centre joined to three leaves.
Number of edges of . In the complete graph every pair of distinct vertices is joined by exactly one edge, so the number of edges equals the number of ways to choose 2 vertices from :
Alternatively, each vertex has degree , so by the handshaking theorem , giving .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 7 marks
Derive the adjacency and incidence matrix representation forms for the following graph. (Graph with vertices V1 to V5 and edges e1 to e8 given in the paper.)
Answer
Take the graph with vertices and edges .
Adjacency matrix. is with if and are joined by an edge (the count of edges if parallel edges exist), else . For an undirected graph it is symmetric.
Row sums give the degrees: .
Incidence matrix. is (vertices by edges) with if vertex is an end of edge , else .
Each column has exactly two 1s (every edge has two end vertices), and each row sum equals the degree of the vertex.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 8 marks
Use Dijkstra's algorithm to find the length of shortest path from 'a' to 'z' in the following weighted graph. Also highlight the shortest path in the graph.
Answer
Consider the weighted graph with edges .
Dijkstra's algorithm. Set and all other labels . Repeatedly fix the unfixed vertex with the smallest label and relax the labels of its neighbours.
| Step | Fixed | b | c | d | e | z |
|---|---|---|---|---|---|---|
| 0 | a (0) | 4 | 2 | |||
| 1 | c (2) | 3 | 2 | 10 | 12 | |
| 2 | b (3) | 3 | 2 | 8 | 12 | |
| 3 | d (8) | 3 | 2 | 8 | 10 | 14 |
| 4 | e (10) | 3 | 2 | 8 | 10 | 13 |
| 5 | z (13) | 13 |
Labels at each step: after fixing , , , ; after fixing , ; after fixing , and ; after fixing , .
Tracing predecessors back from : .
Shortest path: , of length . These edges are the ones highlighted in the graph.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 7 marks
Verify following argument is valid using the rules of inference: "If I work hard, then I will get job" and "If I get job then I'll be happy." "I will not be happy." Therefore, "Either I will not get job or I will not work hard".
Answer
Let : I work hard; : I get a job; : I will be happy.
Premises: , , .
Conclusion: .
| Step | Statement | Reason |
|---|---|---|
| 1 | Premise | |
| 2 | Premise | |
| 3 | Hypothetical syllogism (1, 2) | |
| 4 | Premise | |
| 5 | Modus tollens (3, 4) | |
| 6 | Addition (5) | |
| 7 | Commutative law (6) |
Hence the argument is valid.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 8 marks
Express above statement using quantifiers where domain consist of all animals
i. No tigers are herbivorous.
ii. All herbivorous animals are prey.
iii. No prey is a tiger.
iv. Some tigers are omnivorous.
Answer
Let the domain be all animals, with predicates : is a tiger; : is herbivorous; : is prey; : is omnivorous.
(i) No tigers are herbivorous.
(ii) All herbivorous animals are prey.
(iii) No prey is a tiger.
(iv) Some tigers are omnivorous.
A universal statement uses and an existential statement uses .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 7 marks
Define indirect proof. Prove that if n is an integer and is odd, then n is even using indirect proof.
Answer
Indirect proof. A proof of that does not start from and reach directly. Two forms are used: proof by contrapositive (prove , which is equivalent to ) and proof by contradiction (assume and derive a contradiction).
Claim. If is an integer and is odd, then is even.
Proof (contrapositive). We prove: if is odd, then is even.
Let be odd, so for some integer . Then
Since is an integer, is even.
So the contrapositive is true, and therefore the original statement is true: if is odd, then is even.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 8 marks
Using the truth table, prove the following logical equivalence
i. (given in the paper)
ii.
iii.
Answer
(i) De Morgan's law: .
| T | T | T | F | F | F | F |
| T | F | T | F | F | T | F |
| F | T | T | F | T | F | F |
| F | F | F | T | T | T | T |
The columns for and are identical, so they are equivalent.
(ii) .
| T | T | F | F | T | F | T |
| T | F | F | T | F | T | F |
| F | T | T | F | T | F | T |
| F | F | T | T | T | F | T |
The columns for and are identical, so the equivalence holds.
(iii) (idempotent law).
| T | T |
| F | F |
The column of equals the column of , so .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 7 marks
Consider the following Grammar: , , , . Determine whether the given grammar is Context-sensitive, Context Free, Regular or none of these.
Answer
Productions: , , , .
Test for Context-Free / Regular. A context-free grammar needs every production to have a single non-terminal on the left. Here , and have two symbols on the left, so the grammar is not context-free, and hence not regular.
Test for Context-Sensitive. A context-sensitive (type 1) grammar needs for every production (non-contracting, with no rule shortening a string):
| Production | Non-contracting? | ||
|---|---|---|---|
| 1 | 4 | Yes | |
| 2 | 3 | Yes | |
| 2 | 2 | Yes | |
| 2 | 2 | Yes |
All productions satisfy .
Conclusion: the grammar is context-sensitive (type 1). It is neither context-free nor regular.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 5 marks
Write short notes on: Regular expression
Answer
Regular expression (RE). A regular expression is an algebraic way of describing a language over an alphabet . It is defined recursively:
- (empty set), (empty string) and each symbol are regular expressions.
- If and are regular expressions, so are:
- (union, also written ): strings from or .
- (concatenation): a string from followed by a string from .
- (Kleene star): zero or more strings from concatenated.
- Nothing else is a regular expression.
Examples over :
| Expression | Language |
|---|---|
| all strings over | |
| strings ending with | |
| strings starting with and ending with | |
Key results.
- The languages described by regular expressions are exactly the regular languages, those accepted by DFAs/NFAs and generated by regular (type 3) grammars (Kleene's theorem).
- Some algebraic laws: , , , , .
Uses: pattern matching in text editors and grep, lexical analysis in compilers, and input validation.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Fall · 5 marks
Write short notes on: Tautology, contradiction, contingent
Answer
Tautology. A compound proposition that is true for all possible truth values of its component propositions. Example: .
Contradiction. A compound proposition that is false for all possible truth values of its components. Example: .
Contingency. A compound proposition that is neither a tautology nor a contradiction, so it is true for some assignments and false for others. Example: , or .
| (tautology) | (contradiction) | (contingency) | ||
|---|---|---|---|---|
| T | F | T | F | T |
| F | T | T | F | F |
Relations:
- The negation of a tautology is a contradiction, and the negation of a contradiction is a tautology.
- The negation of a contingency is a contingency.
- exactly when is a tautology.
Whether a proposition is one of these three types is checked by a truth table or by logical laws.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
What is the degree sequence of , where n is a positive integer? How many subgraphs with at least one vertex does have? Draw the structure of following graphs: , , , ,
Answer
Degree sequence of . Every vertex of is adjacent to the other vertices, so every vertex has degree . The degree sequence is
and the number of edges is .
Subgraphs of with at least one vertex. has vertices and one edge . The subgraphs are:
- (one vertex, no edge)
- with no edge
- with edge (the whole graph)
So there are 4 subgraphs.
The graphs:
| Graph | Structure | Vertices | Edges |
|---|---|---|---|
| 6 vertices placed on a hexagon, every pair joined (each vertex has degree 5) | 6 | 15 | |
| Two sets and ; each joined to every , no edge inside a set | 7 | 12 | |
| A hexagon plus a hub vertex joined to all 6 corners | 7 | 12 | |
| A single 6-cycle (hexagon) | 6 | 6 | |
| The cube: vertices are the binary strings of length 3, edges join strings differing in one bit | 8 | 12 |
Drawing guide: for , draw two squares (one inside the other, or one shifted) for strings starting with and with , and join corresponding corners; each vertex has degree 3.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
Explain and prove Handshaking theorem. Is planar graph? Explain with reason.
Answer
Handshaking theorem. In any undirected graph ,
That is, the sum of the degrees of all vertices is twice the number of edges. (A loop adds 2 to the degree of its vertex.)
Proof. Every edge has two end points, so it contributes exactly 1 to the degree of each of its two end vertices (or 2 to one vertex, for a loop). Summing the degrees over all vertices therefore counts each edge exactly twice. Hence .
Corollary. The number of vertices of odd degree is even. Since is even and the even-degree vertices contribute an even amount, the odd-degree vertices must contribute an even total, which needs an even count of them.
Is planar? No.
has vertices and edges. Suppose it were planar. Euler's formula gives , so faces.
is bipartite, so it has no odd cycles and in particular no triangle. Every face is therefore bounded by at least 4 edges. Each edge borders at most two faces, so
which is false. Equivalently, a simple bipartite planar graph satisfies , but .
This contradiction shows that is not planar (by Kuratowski's theorem it is one of the two basic non-planar graphs, together with ).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
Find the shortest path between 'a' and 'g' using Dijkstra's algorithm for the following graph. (Weighted graph given in the paper.)
Answer
Consider the weighted graph with edges .
Dijkstra's algorithm. Label with and all other vertices with . At each step fix the unfixed vertex with the smallest label and relax the labels of its neighbours.
| Step | Fixed | b | c | d | e | g |
|---|---|---|---|---|---|---|
| 0 | a (0) | 2 | 4 | |||
| 1 | b (2) | 2 | 3 | 9 | ||
| 2 | c (3) | 2 | 3 | 9 | 6 | |
| 3 | e (6) | 2 | 3 | 8 | 6 | 12 |
| 4 | d (8) | 2 | 3 | 8 | 6 | 9 |
| 5 | g (9) | 9 |
Relaxations: from , and ; from , ; from , and ; from , .
Tracing predecessors from : .
Shortest path: , of length .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
Define the Euler circuit and Hamilton Circuit. Give an example of a connected graph with Euler circuit but no Hamiltonian circuit.
Answer
Euler circuit. A circuit (closed walk) in a graph that uses every edge exactly once. A connected graph has an Euler circuit if and only if every vertex has even degree.
Hamilton circuit. A simple cycle in a graph that passes through every vertex exactly once and returns to the starting vertex.
Example: connected graph with an Euler circuit but no Hamilton circuit. The "bowtie" (butterfly) graph: two triangles and sharing the common vertex . It has 5 vertices and 6 edges: .
- Euler circuit exists: and , all even, and the graph is connected. The circuit is , which uses all 6 edges once.
- No Hamilton circuit: the vertex is a cut vertex (removing it disconnects the graph). Any cycle through all vertices would have to pass through twice, once to go between the two triangles and again to come back, but a Hamilton circuit may visit each vertex only once. Hence no Hamilton circuit exists.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
What is logical Equivalence? Solve the following.
i. Show that is contradiction.
ii. Prove the condition for contrapositive using truth table.
Answer
Logical equivalence. Two compound propositions and are logically equivalent, written , if they always have the same truth value, that is, if is a tautology. Example: .
(i) Show that is a contradiction.
| T | T | T | F | F | F | F |
| T | F | T | F | T | F | F |
| F | T | T | T | F | F | F |
| F | F | F | T | T | T | F |
The last column is false in every row, so the proposition is a contradiction.
(Algebraically, by De Morgan's law, so the expression is , which is always false.)
(ii) Contrapositive. The contrapositive of is . We show .
| T | T | F | F | T | T |
| T | F | F | T | F | F |
| F | T | T | F | T | T |
| F | F | T | T | T | T |
The last two columns are identical, so an implication is logically equivalent to its contrapositive.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
Show the hypothesis, "If it's sunny today, then we will have swimming today, if we do not have swimming today, then we will have swimming tomorrow. Therefore, if it's sunny today, then will we have swimming tomorrow.
Answer
Let : it is sunny today; : we have swimming today; : we have swimming tomorrow.
Hypotheses: and .
Conclusion to test: .
Test. For the argument to be valid, the conclusion must be true whenever both hypotheses are true. Take , , :
- is .
- is .
- is .
Both hypotheses are true while the conclusion is false, so the argument is not valid as stated. In words, it is sunny and we swim today, which satisfies both premises, but nothing forces swimming tomorrow.
The two hypotheses chain in a valid way only if the second one is , which gives, by hypothetical syllogism:
| Step | Statement | Reason |
|---|---|---|
| 1 | Premise | |
| 2 | Premise | |
| 3 | Hypothetical syllogism (1, 2) |
With the premise as given, no such chain exists, since does not connect to .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
Explain proof by Contradiction. Solve that if m and n are odd (statement as given in the paper) using Contradiction approach.
Answer
Proof by contradiction. To prove a statement (or an implication ), assume the opposite, that is, assume (or ), and reason with valid steps until a contradiction is reached: either a statement of the form or a result that contradicts a known fact or the hypotheses. Since valid reasoning from a true assumption cannot produce a falsehood, the assumption must be false, so the original statement is true.
Statement. If and are odd integers, then is odd (and is even).
Proof that is odd. Suppose and are odd but is not odd, i.e. is even.
Write and for integers . Then
which is of the form with an integer, so is odd. This contradicts the assumption that is even. Hence is odd.
Proof that is even. Suppose instead that is odd. Then
which is even, contradicting the assumption. Hence is even.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
Use mathematical induction to prove that is divisible by 8, for .
Answer
Let : is divisible by 8.
Basis step (). , which is divisible by 8. So is true.
Inductive hypothesis. Assume is true for some , i.e. for some integer .
Inductive step. We must show is divisible by 8. Write
- By the hypothesis, , divisible by 8.
- is odd, so is even, say . Then , divisible by 8.
Hence is divisible by 8, so is true.
By the principle of mathematical induction, is divisible by 8 for all .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
Solve the recurrence relation for , , and .
Answer
Characteristic equation. For put :
The roots are (distinct), so the general solution is
Initial conditions.
- :
- :
- :
Subtracting the first from the third gives , so . Then and , so , .
Check. , and the formula gives . ✓
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 8 marks
An employee joined a company in 2019 with a starting salary of 520,000 Rs per year. Every year this employee receives a raise of 5% of the salary of the previous year.
i. Set up a recurrence relation for the salary of this employee.
ii. Find an explicit formula for the salary of this employee n years after 2019.
iii. What will the salary of this employee be in 2025?
Answer
Let be the salary (in Rs) years after 2019, so .
(i) Recurrence relation. Each year the salary is the previous salary plus 5% of it:
(ii) Explicit formula. This is a first-order linear homogeneous recurrence with root , so . Using gives :
(iii) Salary in 2025. 2025 is years after 2019.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 7 marks
Design DFA over which accepts:
i. The set of strings with even number of 1s and even number of 0s.
ii. The set of strings that do not contain two consecutive 0s.
Answer
(i) Even number of 0s and even number of 1s.
Track the parity of 0s and of 1s. States (parity of 0s, parity of 1s): (even, even), (odd, even), (even, odd), (odd, odd).
with , , start state , .
| State | on 0 | on 1 |
|---|---|---|
Reading a 0 flips the parity of 0s; reading a 1 flips the parity of 1s. The string is accepted exactly when both parities are even, i.e. it ends in . The empty string is accepted.
(ii) Strings with no two consecutive 0s.
States: = start / last symbol was 1 (or nothing read), = last symbol was 0, = dead (two consecutive 0s seen). Final states: ; start state .
| State | on 0 | on 1 |
|---|---|---|
1 1
+---+ 0 +---+
v | ------> | |
-->((A))--- ((B))
^ <------ \
| 1 ---------- \ 0
+-------- v
D (loops on 0,1)
That is: , , , , and loops on both 0 and 1. For example, is accepted, while ends in and is rejected.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 5 marks
Write short notes on: Types of quantifiers
Answer
A quantifier states how many elements of the domain make a predicate true. The two basic types are:
1. Universal quantifier (). means " is true for every in the domain". It is false if there is at least one counterexample. Example: over the real numbers.
2. Existential quantifier (). means "there is at least one in the domain for which is true". It is false only when is false for every . Example: .
Related forms:
- Uniqueness quantifier (): means there is exactly one with true.
- Negation (De Morgan for quantifiers):
- Nested quantifiers such as are order-sensitive: is true over the integers, but is false.
A variable bound by a quantifier is a bound variable; otherwise it is free.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 5 marks
Write short notes on: Isomorphism Graph
Answer
Two simple graphs and are isomorphic if there is a bijection such that vertices are adjacent in if and only if are adjacent in . Isomorphic graphs have the same structure and differ only in how vertices are named or drawn.
Invariants (necessary conditions). If then they must have:
- the same number of vertices and the same number of edges,
- the same degree sequence,
- the same number of cycles of each length, the same connectivity, and the same number of components.
If any invariant differs, the graphs are not isomorphic. Equal invariants alone do not prove isomorphism; an explicit bijection must be exhibited.
Example. : edges (a 4-cycle). : edges . The map preserves adjacency, so .
Another way to test: two graphs are isomorphic iff their adjacency matrices differ only by a permutation of rows and columns. The general problem has no known fast algorithm, but it is easy for small graphs.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2024 Spring · 5 marks
Write short notes on: Steps for NFA to DFA
Answer
Every NFA has an equivalent DFA, obtained by the subset construction. Given NFA :
- Start state. The DFA start state is (for an -NFA, use ).
- Transitions. For each DFA state and each symbol compute (with -closure applied to the result for an -NFA).
- New states. Each new subset obtained becomes a DFA state; repeat step 2 for it. The empty set acts as the dead state.
- Stop when no new subsets appear. At most states can result.
- Final states. A DFA state is final if it contains at least one NFA final state.
- Optionally minimise the DFA.
Example. NFA with , , , final state .
| DFA state | on 0 | on 1 |
|---|---|---|
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 8 marks
Draw , , and Graph (as given in the paper). What is the number of vertices in an undirected connected graph with 27 edges, 6 vertices of degree 2, 3 vertices of degree 4 and remaining vertices of degree 3.
Answer
Graphs.
- (complete graph on 5 vertices): every pair of the 5 vertices is joined. Edges , each vertex has degree 4. Drawn as a regular pentagon with all 5 sides and all 5 diagonals (the pentagram).
- (wheel): a cycle on the rim plus a hub vertex joined to every rim vertex. It has 6 vertices and edges; the hub has degree 5 and rim vertices have degree 3.
- (cycle): 6 vertices with edges and ; a hexagon with 6 edges, every vertex of degree 2.
- (complete bipartite): two sets and , every joined to every . It has 7 vertices and edges; the have degree 4, the degree 3.
K5: pentagon + all diagonals W5: pentagon + hub joined to all 5
C6: hexagon K3,4: a1 a2 a3
| X X | (every a to every b)
b1 b2 b3 b4
Number of vertices. By the handshaking theorem, the sum of degrees .
Known degrees: . Let be the number of remaining vertices, each of degree 3:
Total vertices .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
Define walk, path, circuit and trail with examples. What are the applications of graph theory?
Answer
Let be a graph.
- Walk: an alternating sequence of vertices and edges where each edge joins and . Vertices and edges may repeat. The length is the number of edges.
- Trail: a walk in which no edge is repeated (vertices may repeat).
- Path: a walk in which no vertex is repeated (hence no edge is repeated either).
- Circuit: a closed trail, i.e. it starts and ends at the same vertex (), with no repeated edge, of length at least 1. A closed path with no other repeated vertex is a cycle.
Example. Take edges .
- Walk: (repeats edge and vertex ).
- Trail: using (no repeated edge, vertex repeated).
- Path: (no repeated vertex).
- Circuit: using (closed, no repeated edge); also .
Applications of graph theory.
- Computer networks: modelling topology, routing and shortest paths (Dijkstra).
- Transportation and maps: road networks, GPS navigation, airline routes (Euler/Hamilton circuits, travelling salesman).
- Social networks: friendship graphs, community detection.
- Scheduling and timetabling via graph colouring; frequency assignment.
- Compilers and software: control-flow graphs, dependency graphs, register allocation.
- Databases and web: link structure and ranking of web pages, search.
- Chemistry and biology: molecular structures, food webs, circuit design (planar graphs).
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 8 marks
What is single source shortest path algorithm? Explain Dijkstra Algorithm. Given the weighted graph use Dijkstra Algorithm to find the shortest path from vertex a to z.
Answer
Single-source shortest path problem. Given a weighted graph with non-negative edge weights and a source vertex , find the minimum-weight path from to every other vertex (or to a chosen target).
Dijkstra's algorithm.
- Set and for all other vertices; mark all vertices as unvisited.
- Pick the unvisited vertex with the smallest and mark it permanent (visited).
- For every neighbour of : if , set and record as the predecessor of (relaxation).
- Repeat steps 2-3 until the target is visited (or all vertices are visited).
- Trace predecessors back from the target to read off the path.
It works because with non-negative weights, the smallest tentative distance is already final. With a binary heap its running time is .
Worked example. Graph with edges: . Find the shortest path from to .
| Step | Visited | ||||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 4 | 2 | ||||
| 1 | 0 | 3 | 2 | 10 | 12 | ||
| 2 | 0 | 3 | 2 | 8 | 12 | ||
| 3 | 0 | 3 | 2 | 8 | 10 | 14 | |
| 4 | 0 | 3 | 2 | 8 | 10 | 13 | |
| 5 | 0 | 3 | 2 | 8 | 10 | 13 |
Tracing predecessors: .
Shortest path: with length .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
Find the adjacency matrix and adjacency list of following graph. (Graph given in the paper.)
Answer
Consider the graph with vertices and edges .
Adjacency matrix. where if and are adjacent, else (for a loop-free undirected graph it is symmetric with zero diagonal).
Row sums give the degrees: (total edges).
Adjacency list. Each vertex is stored with the list of its neighbours.
| Vertex | Adjacent vertices |
|---|---|
The matrix needs space and tests adjacency in ; the list needs space and suits sparse graphs. For a directed graph, only when there is an edge from to , and the list stores out-neighbours.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 8 marks
What is logical equivalence?
i. Prove that the converse and the inverse of a conditional statement are also equivalent
ii. Show that the following statements are equivalent.
Statement 1: Rich men are unhappy.
Statement 2: Men are unhappy or poor.
Answer
Logical equivalence. Two compound propositions and are logically equivalent () if they have the same truth value in every possible case, i.e. is a tautology.
(i) Converse and inverse of a conditional are equivalent.
For : the converse is , the inverse is .
Since (commutative law), the converse and inverse are equivalent. Truth table check:
| T | T | T | T |
| T | F | T | T |
| F | T | F | F |
| F | F | T | T |
The last two columns are identical. (They are contrapositives of each other.)
(ii) "Rich men are unhappy" "Men are unhappy or poor".
Let : the man is rich, : the man is unhappy, : the man is poor. "Not rich" is taken as poor, so .
- Statement 1: .
- Statement 2: .
Using the conditional law :
Hence the two statements are logically equivalent.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
State the principle of Mathematical Induction? Use mathematical induction to show that , for all nonnegative integers n.
Answer
Principle of mathematical induction. Let be a statement about non-negative integers. If
- (Basis step) is true, and
- (Inductive step) for every , ,
then is true for all integers .
Claim. : for all .
Basis step (). LHS , RHS . So holds.
Inductive hypothesis. Assume : .
Inductive step. Then
which is .
By induction, for all non-negative integers .
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 8 marks
What do you mean by valid arguments. Construct an argument using rules of inference to show that the hypotheses "If it does not rain or if it is not foggy, then the sailing race will be held and the life saving demonstration will go on", "If the sailing race is held, then the trophy will be awarded", and "The trophy was not awarded" imply the conclusion "it rained".
Answer
Valid argument. An argument with hypotheses and conclusion is valid if is a tautology, i.e. whenever all the hypotheses are true, the conclusion is also true. It is shown valid using rules of inference.
Symbols. : it rains; : it is foggy; : the sailing race is held; : the life saving demonstration goes on; : the trophy is awarded.
Hypotheses.
Conclusion: .
| Step | Statement | Reason |
|---|---|---|
| 1 | Hypothesis 2 | |
| 2 | Hypothesis 3 | |
| 3 | Modus tollens (1, 2) | |
| 4 | Addition (3) | |
| 5 | De Morgan (4) | |
| 6 | Hypothesis 1 | |
| 7 | Modus tollens (5, 6) | |
| 8 | De Morgan (7) | |
| 9 | Simplification (8) |
Hence "it rained" follows from the hypotheses, so the argument is valid.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
Show that is irrational using proof by contradiction.
Answer
Claim. is irrational.
Proof by contradiction. Suppose is rational. Then where are integers, , and (the fraction is in lowest terms).
Squaring: , so
Thus is even, which forces to be even (the square of an odd number is odd). Write for an integer . Then
so is even and therefore is even.
Now both and are even, so 2 divides both, contradicting .
The assumption was false. Hence cannot be written as a ratio of integers, i.e. is irrational.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 7 marks
Solve the recurrence relation , where .
Answer
Solve , .
Homogeneous part. (root ).
Particular solution. The non-homogeneous term is (a polynomial of degree 1), and 1 is not a root, so try :
Comparing coefficients: ; .
So .
General solution. .
Initial condition. : .
Check. ; formula: . ✓
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 8 marks
State tuples used in Finite Automata. Design a Finite State Automata with strings over {a, b} that containing ending with a. Your design should include proper Finite State Automata, transition table and transition Diagram.
Answer
Tuples of a finite automaton. A finite automaton is a 5-tuple :
- : a finite set of states,
- : a finite input alphabet,
- : the transition function ( for a DFA; for an NFA),
- : the start state,
- : the set of final (accepting) states.
Design: strings over ending with .
, where means "the last symbol read was " and means "nothing read yet, or the last symbol was ".
Transition table.
| State | ||
|---|---|---|
Transition diagram.
b a
+---+ +---+
v | v |
--> (q0)-----a------>((q1))
^ |
+--------b--------+
loops on , goes to on ; loops on , returns to on . Example: takes and is accepted; ends in and is rejected.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 5 marks
Write short notes on: Quantification
Answer
Quantification is the process of turning a predicate (propositional function) , which has no truth value until is given a value, into a proposition by specifying how many values of satisfy it.
The two main forms:
- Universal quantification : is true for all in the domain. It is false if a single counterexample exists.
- Existential quantification : is true for at least one in the domain. It is false if fails for every .
Examples (domain: real numbers): is true; is false.
Negation rules:
Translation: "All students are intelligent" is ; "Some students are intelligent" is .
The domain of discourse must be specified, quantified variables are bound, and with several quantifiers the order matters.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
- 2023 Spring · 5 marks
Write short notes on: Context Free Grammar
Answer
A context-free grammar (CFG) is a 4-tuple :
- : a finite set of variables (non-terminals),
- : a finite set of terminals, disjoint from ,
- : a finite set of productions of the form , where and (the left side is a single non-terminal, so the rule applies regardless of context),
- : the start symbol.
The language generated is . Languages generated by CFGs are called context-free languages (Type 2 in the Chomsky hierarchy) and are recognised by pushdown automata.
Example. with generates . Derivation of : .
Concepts. Derivations can be leftmost or rightmost; the parse (derivation) tree shows the structure of a derivation. A grammar is ambiguous if some string has two different parse trees.
Uses: specifying the syntax of programming languages (BNF), parsers in compilers, expression evaluation, and XML/HTML structure.
Answer checked by Claude Sonnet · Oct 21, 2026
Test yourself · 2 MCQs
Loading…
Questions from PU BCA 2025 Spring Numerical Methods (Pokhara University BCA, Spring 2025), PU BCA 2024 Spring Numerical Methods (Pokhara University BCA, Spring 2024), PU BCA 2023 Spring Numerical Methods (Pokhara University BCA, Spring 2023), PU BCA 2025 Spring Mathematical Foundation of Computer Science (Pokhara University BCA, Spring 2025), PU BCA 2024 Fall Mathematical Foundation of Computer Science (Pokhara University BCA, Fall 2024), PU BCA 2024 Spring Mathematical Foundation of Computer Science (Pokhara University BCA, Spring 2024), PU BCA 2023 Spring Mathematical Foundation of Computer Science (Pokhara University BCA, Spring 2023) and PU BCA 2025 Spring Data Communication and Computer Network (Pokhara University BCA, Spring 2025). Answers are written for this site; check them against your class notes.