All 25 questions UPSC has asked on Boolean algebra, logic gates and computer systems in the Mathematics Optional (Paper II, Numerical Analysis and Computer Programming) from 2008 to 2026, solved step by step – latest first.
Try them yourself first: the same questions, without solutions, are on our Numerical Analysis and Computer Programming topic-wise PYQs page.
How we check these solutions
These are our own solutions, prepared with AI help. UPSC does not publish official answers. Every solution is checked a second way before it goes up, and says how:
- ✓ Checked by computer the answer was worked out again independently with Python: each iteration, table or conversion was run again in double precision (or exact fractions), and algorithms were run on test equations.
- ✓ Proof checked step by step for “prove that” questions, every step was checked against the definitions.
Spotted a mistake or a neater method? Tell us in the comments below or through Report an error.
Jump to a question (year · question number):
2026 · 5c 2025 · 5c 2025 · 6b 2024 · 6b 2023 · 7a 2022 · 5c 2022 · 6b 2021 · 5c 2021 · 6b 2020 · 5c 2019 · 8a 2018 · 8a 2017 · 5c 2016 · 8c 2015 · 5c 2014 · 5d 2014 · 8b 2011 · 5d 2011 · 7b 2010 · 5d 2010 · 7c 2009 · 5c(ii) 2009 · 5d(i) 2008 · 5d(i) 2008 · 5d(ii)
Consider the logic circuit : [Figure: logic circuit with inputs , , ; the first AND gate takes , , ; the second AND gate takes , (through a NOT gate) and ; the third AND gate takes (through a NOT gate) and ; the outputs of the three AND gates feed an OR gate whose output is ] (i) Express as a Boolean expression. (ii) Write 8-bit special sequences for , and . (iii) Find the truth table of using 8-bit special sequences.
Solution
(i) Boolean expression. The three AND gates give , and ; the OR gate adds them: It simplifies: , so .
(ii) 8-bit special sequences. For three inputs, list the 8 input combinations column-wise; each input then becomes an 8-bit string: (Read vertically, bit of is the binary form of .)
(iii) Truth table, working bit by bit (, ):
| Signal | Bits |
|---|---|
| 00001111 | |
| 00110011 | |
| 01010101 | |
| 00000001 | |
| 00000100 | |
| 00110000 | |
| (OR) | 00110101 |
As an ordinary truth table:
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
✓ Checked by computer We checked by computer: bitwise evaluation of the three AND terms and their OR gives , which equals row by row.
(i) Convert the number into binary system and the number into decimal system. (ii) Determine the truth table for the Boolean function Also derive the full disjunctive normal form of from the truth table.
Solution
(i) to binary. Repeated division by 2:
| Divide by 2 | Quotient | Remainder |
|---|---|---|
| 3479 | 1739 | 1 |
| 1739 | 869 | 1 |
| 869 | 434 | 1 |
| 434 | 217 | 0 |
| 217 | 108 | 1 |
| 108 | 54 | 0 |
| 54 | 27 | 0 |
| 27 | 13 | 1 |
| 13 | 6 | 1 |
| 6 | 3 | 0 |
| 3 | 1 | 1 |
| 1 | 0 | 1 |
Reading the remainders from the bottom up, (Check: .)
to decimal. , , :
(ii) Truth table for :
| 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Full disjunctive normal form. Take one minterm for each row with : (As a check: exactly when (first factor 0) or (second factor 0), i.e. rows 1, 6, 7.)
✓ Checked by computer We checked by computer: , , and the truth table of has 1s exactly in rows 0, 2, 3, 4, 5.
Simplify the Boolean function and draw the corresponding GATE network.
Solution
Use (idempotent law) to pair the extra term with each of the others: So – the majority function (1 when at least two inputs are 1). No further simplification is possible: each term covers a pair of minterms not covered by the others.
Gate network: three 2-input AND gates and one 3-input OR gate.
✓ Checked by computer We checked by computer: and agree on all 8 inputs.
Draw the logical circuit for the Boolean expression . Also, obtain the output (truth table) for the three input bit sequences : , ,
Solution
Logic circuit. Three AND gates for , and (NOT gates supply and ), followed by a 3-input OR gate.
(The expression simplifies: , so .)
Output for the given sequences, bit by bit:
| Signal | Bits |
|---|---|
| 10001111 | |
| 00111100 | |
| 11000100 | |
| 00001000 | |
| 00111000 | |
| 00110000 | |
| 00111000 |
So .
✓ Checked by computer We checked by computer: bitwise, ; the simplified form gives the same bits.
(i) Find the conjunctive normal form (CNF) of the following Boolean function : \(ii\) Express the Boolean function in disjunctive normal form (DNF) and construct the truth table for the function.
Solution
(i) Factor out : For any : (expand the right side: , and is the consensus term, already covered). With , : Hence the conjunctive normal form is
(ii) By De Morgan, . Therefore So the (simplest) DNF is . As a full DNF, is the sum of all minterms except : Truth table (with ):
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
✓ Checked by computer We checked by computer (SymPy): is equivalent to the given , and is equivalent to .
(i) Convert the number into octal and the number into hexadecimal systems. (ii) Express the Boolean function in a product of maxterms form.
Solution
(i) to octal.
| Divide by 8 | Quotient | Remainder |
|---|---|---|
| 1093 | 136 | 5 |
| 136 | 17 | 0 |
| 17 | 2 | 1 |
| 2 | 0 | 2 |
| Fraction × 8 | Product | Integer part |
|---|---|---|
| 0.21875 × 8 | 1.75 | 1 |
| 0.75 × 8 | 6 | 6 |
The fraction terminates, so (Check: .)
to hexadecimal.
| Divide by 16 | Quotient | Remainder |
|---|---|---|
| 1693 | 105 | D (13) |
| 105 | 6 | 9 |
| 6 | 0 | 6 |
| Fraction × 16 | Product | Integer part |
|---|---|---|
| 0.0628 × 16 | 1.0048 | 1 |
| 0.0048 × 16 | 0.0768 | 0 |
| 0.0768 × 16 | 1.2288 | 1 |
| 0.2288 × 16 | 3.6608 | 3 |
| 0.6608 × 16 | 10.5728 | A (10) |
The fraction does not terminate:
(ii) Product of maxterms for . for : rows (minterms 6, 7); for : rows (minterms 1, 3). So and in rows 0, 2, 4, 5. Each zero row gives a maxterm (a variable appears uncomplemented where it is 0):
✓ Checked by computer We checked by computer: , , and is 0 exactly in rows 0, 2, 4, 5.
Find a combinatorial circuit corresponding to the Boolean function and write the input/output table for the circuit.
Solution
Multiplying out, . A two-level circuit: AND gates for and (a NOT gate makes ), and an OR gate that also takes directly.
Input/output table:
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 |
The output column is 1 exactly when or . Indeed and is then absorbed, so which needs just one OR gate:
✓ Checked by computer We checked by computer: and agree on all 8 inputs.
(i) Convert into octal and hexadecimal equivalents. (ii) Obtain the principal conjunctive normal form of .
Solution
(i) . Integer part to octal and to hexadecimal:
| Divide by 8 | Quotient | Remainder |
|---|---|---|
| 3798 | 474 | 6 |
| 474 | 59 | 2 |
| 59 | 7 | 3 |
| 7 | 0 | 7 |
| Divide by 16 | Quotient | Remainder |
|---|---|---|
| 3798 | 237 | 6 |
| 237 | 14 | D (13) |
| 14 | 0 | E (14) |
So .
Fraction to octal (×8) and to hexadecimal (×16):
| Fraction × 8 | Product | Integer part |
|---|---|---|
| 0.3875 × 8 | 3.1 | 3 |
| 0.1 × 8 | 0.8 | 0 |
| 0.8 × 8 | 6.4 | 6 |
| 0.4 × 8 | 3.2 | 3 |
| 0.2 × 8 | 1.6 | 1 |
| 0.6 × 8 | 4.8 | 4 |
| 0.8 × 8 | 6.4 | 6 |
| 0.4 × 8 | 3.2 | 3 |
| Fraction × 16 | Product | Integer part |
|---|---|---|
| 0.3875 × 16 | 6.2 | 6 |
| 0.2 × 16 | 3.2 | 3 |
| 0.2 × 16 | 3.2 | 3 |
| 0.2 × 16 | 3.2 | 3 |
In octal the digits repeat; in hexadecimal the digit 3 repeats. Hence
(ii) Principal conjunctive normal form. , and is true when have the same value.
| Formula | |||||
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 |
The formula is false in rows . Each false row gives a maxterm, so the PCNF is
✓ Checked by computer We checked by computer: , the fraction gives the repeating digits shown, and the formula is false in exactly the five rows used.
Obtain the Boolean function based on the table given below. Then simplify and draw the corresponding GATE network :
Solution
Boolean function. in the rows , so (sum of minterms) Simplify. Using : ( is 1 when at least two of are 1 – the majority function.)
Gate network:
✓ Checked by computer We checked by computer: the minterm sum equals on all 8 inputs.
Let be a Boolean function. Obtain the conjunctive normal form for . Also express as a product of maxterms.
Solution
CNF. is already a product of sums, so a conjunctive normal form is Product of maxterms. Each sum that lacks a variable is expanded with , i.e. : (Maxterm is 0 exactly at input .) Dropping the repeated :
✓ Checked by computer We checked by computer: exactly for the inputs numbered 0, 1, 2, 3, 6, 7, 10 (in the order ), so .
Given the Boolean expression (i) Draw the logical diagram for the expression. (ii) Minimize the expression. (iii) Draw the logical diagram for the reduced expression.
Solution
(i) Logic diagram of the given expression.
(ii) Minimisation. (absorption: and .)
(iii) Logic diagram of the reduced expression: one NOT, one OR and one AND gate.
✓ Checked by computer We checked by computer: and agree on all 8 inputs.
Simplify the boolean expression : by using the laws of boolean algebra. From its truth table write it in minterm normal form.
Solution
Simplification. Truth table:
| Value | |||
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Minterm normal form (one minterm for each row with value 1):
✓ Checked by computer We checked by computer: the given expression equals on all 8 inputs and is 1 for minterms 2–7.
Write the Boolean expression in its simplest form using Boolean postulate rules. Mention the rules used during simplification. Verify your result by constructing the truth table for the given expression and for its simplest form.
Solution
using, in order, the distributive law, , absorption (), the distributive law and absorption again: So the simplest form is .
Verification by truth table:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
The last two columns are identical.
✓ Checked by computer We checked by computer: the last two columns of the truth table agree in every row.
Let , , be Boolean variables, denote complement of , is an expression for OR and is an expression for AND . Then simplify the following expression and draw a block diagram of the simplified expression, using AND and OR gates.
Solution
Use absorption, , on every factor that contains uncomplemented: So the expression reduces to Block diagram (one OR gate, one AND gate):
✓ Checked by computer We checked by computer: the product equals on all 8 inputs.
Find the principal (or canonical) disjunctive normal form in three variables , , for the Boolean expression . Is the given Boolean expression a contradiction or a tautology?
Solution
Write . Since and , The expression is true for every assignment: it is a tautology (not a contradiction).
The principal disjunctive normal form therefore contains all minterms: (Check one row: gives ; any row with false makes both implications true.)
✓ Checked by computer We checked by computer: the expression is true in all 8 rows of its truth table.
Use only AND and OR logic gates to construct a logic circuit for the Boolean expression .
Solution
is a sum of two products: one AND gate for , one for , and an OR gate to combine them.
✓ Proof checked step by step We checked all 16 input combinations: the circuit outputs 1 exactly when or .
For any Boolean variables and , show that .
Solution
Check by truth table: if both sides are 0; if , . Hence (the absorption law).
✓ Proof checked step by step We checked each step against the Boolean algebra laws, and the identity in all four rows of its truth table.
(i) Compute to the base 8. (ii) Let be an arbitrary but fixed Boolean algebra with operations , and and the zero and the unit element denoted by 0 and 1 respectively. Let be elements of . If be such that and then prove that .
Solution
(i) Repeated division by 8:
| Divide by 8 | Quotient | Remainder |
|---|---|---|
| 3205 | 400 | 5 |
| 400 | 50 | 0 |
| 50 | 6 | 2 |
| 6 | 0 | 6 |
(Check: .)
(ii) The complement is unique. By definition satisfies and . Suppose also and . Then (using, in turn, the identity law, , the distributive law and ). In the same way, using and : Since is commutative, , so .
✓ Proof checked step by step We checked each step against the Boolean algebra axioms (identity, complement, distributive and commutative laws); was checked by computer.
Find the logic circuit that represents the following Boolean function. Find also an equivalent simpler circuit :
Solution
only in rows and , so Circuit (sum of minterms):
Simpler circuit. , so a single AND gate does the job:
✓ Checked by computer We checked by computer: and agree with the given table in all 8 rows.
(i) Suppose a computer spends 60 per cent of its time handling a particular type of computation when running a given program and its manufacturers make a change that improves its performance on that type of computation by a factor of 10. If the program takes 100 sec to execute, what will its execution time be after the change ? (ii) If , find the value of .
Solution
(i) Of the 100 s, (60 s) is spent on the improved computation and 40 s on everything else. The improved part becomes 10 times faster: s. The rest is unchanged. New time: (Overall speed-up , not 10 – this is Amdahl’s law.)
(ii) is 1 when exactly one input is 1. Then (using ). So exactly when an odd number of are 1.
✓ Checked by computer We checked by computer: s, and is 1 exactly in rows 1, 2, 4, 7.
(i) Find the hexadecimal equivalent of the decimal number (ii) For the given set of data points write an algorithm to find the value of by using Lagrange’s interpolation formula. (iii) Using Boolean algebra, simplify the following expressions (i) (ii) where represents the complement of .
Solution
(i) Repeated division by 16:
| Divide by 16 | Quotient | Remainder |
|---|---|---|
| 587632 | 36727 | 0 |
| 36727 | 2295 | 7 |
| 2295 | 143 | 7 |
| 143 | 8 | F (15) |
| 8 | 0 | 8 |
(ii) Lagrange’s formula: .
ALGORITHM Lagrange interpolation
Input : n, data points (x[1], f[1]), ..., (x[n], f[n]), the point x
1. sum = 0
2. For i = 1 to n do
term = f[i]
For j = 1 to n do
if j ≠ i then term = term*(x - x[j])/(x[i] - x[j])
end for
sum = sum + term
end for
3. Print "f(x) =", sum
4. Stop
(iii) (a) Using repeatedly: so .
✓ Checked by computer We checked by computer: ; the algorithm, run on the six points of the 2009 interpolation question, returns ; both simplifications were confirmed on all inputs.
Find the values of two valued boolean variables , , , by solving the following simultaneous equations : where denotes the complement of .
Solution
First equation. (since ). So , which forces and : Second equation. with , gives : Third equation. With , , : the left side is , and the right side is . So Solution: (and it is the only one). Check: ✓; ✓; ✓.
✓ Checked by computer We checked by computer: of the 16 possible assignments, only satisfies all three equations.
Realize the following expression by using NAND gates only : where denotes the complement of .
Solution
Use three facts about NAND (written ):
- (inverter),
- (De Morgan),
- .
So, with and , The final inversion is one more NAND with its inputs tied. Gates used: three NAND inverters (for , , ), two NANDs for , , a 4-input NAND, and a NAND inverter at the output.
✓ Checked by computer We checked by computer: the NAND network gives the same output as for all 64 inputs.
State the principle of duality in Boolean algebra and given the dual of the Boolean expressions and
Solution
Principle of duality. Every identity of Boolean algebra remains valid if we interchange the operations and and interchange the constants and throughout (complements and variables are left as they are). The new expression is the dual of the old one. This works because the axioms themselves come in dual pairs (e.g. and ; and ).
Duals.
- has dual
- has dual
✓ Proof checked step by step We checked both duals by interchanging and symbol by symbol, leaving complements unchanged.
Represent in NOR to NOR logic network.
Solution
A product of sums maps directly onto two levels of NOR gates. For sums , De Morgan gives and each is itself a NOR of the literals in : So with the complemented inputs made by NOR gates whose inputs are tied together.
✓ Checked by computer We checked by computer: the NOR–NOR network and the product of sums agree on all 8 inputs.
More on Numerical Analysis and Computer Programming
- Numerical Analysis and Computer Programming topic-wise PYQs (questions only, for practice)
- Mathematics PYQ analysis: which units carry the marks year by year
- Year-wise question papers
- Mathematics booklist
Questions: UPSC Civil Services (Main) Examination, Mathematics Paper II, 2008–2026. Solutions: Optional Province. Found an error? Tell us.

