Blog
Discrete Structure MSc IT 2nd Term Past Paper 2018 UOS
University of Sargodha M.Sc. IT 2nd term Discrete Structure (CMP-2111) past paper 2018, retyped from the original paper, with solved answers below.
Solved answers
Q1 – Short answers
(1) Sequence: a function whose domain is a set of consecutive integers (usually ℕ); its values a₁, a₂, a₃, … are called terms, e.g. 2, 4, 6, 8, … with aₙ = 2n.
(2) Algorithm: a finite sequence of precise, unambiguous instructions for solving a problem or performing a computation; it has input, output, definiteness, finiteness and effectiveness.
(3) Boolean expression: an expression built from Boolean variables (values 0/1) and the operators AND (·), OR (+) and NOT (′), e.g. x·y′ + z.
(4) Forest: an undirected graph with no cycles (acyclic); each connected component of a forest is a tree.
(5) Combination: an unordered selection of r objects from n distinct objects; the number is C(n, r) = n! / (r!(n − r)!).
(6) Undirected graph: a graph G = (V, E) whose edges have no direction; an edge {u, v} connects u and v both ways.
(7) Pseudocode: an informal, language-independent description of an algorithm using programming-like structures (if, while, for) and plain English, intermediate between English and real code.
(8) Tree: a connected undirected graph with no simple circuits; a tree with n vertices has exactly n − 1 edges and a unique path between any two vertices.
(9) Prolog rules: statements in the logic programming language Prolog that define a predicate in terms of others, written head :- body, e.g. grandparent(X,Z) :- parent(X,Y), parent(Y,Z). (“X is a grandparent of Z if X is a parent of Y and Y is a parent of Z”).
(10) Halting problem: the problem of deciding, for any program and input, whether the program eventually halts. Turing proved that no algorithm can solve it in general — it is undecidable.
(11) K-map: a Karnaugh map — a grid representation of a Boolean function in which adjacent cells differ in one variable; grouping adjacent 1s gives a minimised sum-of-products expression.
(12) Binomial theorem: (x + y)ⁿ = Σ (k = 0 to n) C(n, k) xⁿ⁻ᵏ yᵏ, e.g. (x + y)² = x² + 2xy + y².
(13) Bernoulli trial: an experiment with exactly two outcomes, success (probability p) and failure (probability q = 1 − p); the probability of k successes in n independent trials is C(n, k) pᵏ qⁿ⁻ᵏ.
(14) Bipartite graph: a graph whose vertex set can be split into two disjoint sets V₁ and V₂ such that every edge joins a vertex of V₁ to a vertex of V₂ (e.g. K₃,₃). A graph is bipartite iff it has no odd cycle.
(15) Half adder: a combinational circuit that adds two bits x and y, producing Sum = x ⊕ y (XOR) and Carry = x · y (AND).
(16) Pseudograph: a graph that may contain loops (edges from a vertex to itself) and multiple edges between the same pair of vertices.
Q2 – Pigeonhole principle
Statement: if k is a positive integer and k + 1 or more objects are placed into k boxes, then at least one box contains two or more objects. (As a function: a function from a set with k + 1 or more elements to a set with k elements is not one-to-one.)
Proof (by contradiction): suppose none of the k boxes contains more than one object. Then the total number of objects is at most k × 1 = k. This contradicts the fact that there are at least k + 1 objects. Hence some box contains at least two objects. ∎
Generalised pigeonhole principle: if N objects are placed into k boxes, at least one box contains at least ⌈N/k⌉ objects. Proof: if every box had fewer than ⌈N/k⌉ objects, i.e. at most ⌈N/k⌉ − 1 < N/k objects, the total would be less than k·(N/k) = N, a contradiction.
Examples: among any 367 people at least two share a birthday (366 possible days); among 100 people at least ⌈100/12⌉ = 9 were born in the same month.
Q3 – Path of length δ(G) and cycle of length at least δ(G) + 1
Let δ = δ(G) be the minimum degree of G and let P = x₀x₁…xₖ be a longest path in G.
Path: every neighbour of the end-vertex xₖ must lie on P — otherwise P could be extended by that neighbour, contradicting maximality. xₖ has at least δ neighbours, all among x₀, …, xₖ₋₁, so k ≥ δ. Hence G contains a path of length (at least) δ, and in particular a path of length exactly δ (take a part of P).
Cycle (δ ≥ 2): let i be the smallest index such that xᵢ is adjacent to xₖ. Since xₖ has at least δ neighbours among x₀, …, xₖ₋₁, we have i ≤ k − δ. Then xᵢ xᵢ₊₁ … xₖ xᵢ is a cycle (it has at least three vertices because δ ≥ 2) of length k − i + 1 ≥ δ + 1. ∎
(The condition δ(G) ≥ 2 is needed: a tree has δ = 1 and contains no cycle.)
Q4
(a) Circuit for (~P ∧ Q) ∨ ~Q: P goes through a NOT gate; its output and Q go into an AND gate; Q also goes through a second NOT gate; the AND output and ~Q go into an OR gate whose output is the expression.
P ──[NOT]── ~P ──┐
[AND]── (~P ∧ Q) ──┐
Q ───────────────┘ [OR]── (~P ∧ Q) ∨ ~Q
Q ──[NOT]── ~Q ─────────────────────┘| P | Q | ~P ∧ Q | ~Q | (~P ∧ Q) ∨ ~Q |
|---|---|---|---|---|
| T | T | F | F | F |
| T | F | F | T | T |
| F | T | T | F | T |
| F | F | F | T | T |
Simplification: (~P ∧ Q) ∨ ~Q ≡ (~P ∨ ~Q) ∧ (Q ∨ ~Q) ≡ ~P ∨ ~Q ≡ ~(P ∧ Q), so the same output can be produced by a single NAND gate.
(b) If a | b and b | c then a | c. Since a | b, b = ar for some integer r. Since b | c, c = bs for some integer s. Then c = (ar)s = a(rs). Because rs is an integer (product of integers), a divides c. ∎
Q5
(a) (A − B) ∩ (C − B) = (A ∩ C) − B is true for all sets.
x ∈ (A − B) ∩ (C − B) ⇔ (x ∈ A and x ∉ B) and (x ∈ C and x ∉ B) ⇔ x ∈ A and x ∈ C and x ∉ B ⇔ x ∈ A ∩ C and x ∉ B ⇔ x ∈ (A ∩ C) − B. Both sides have exactly the same elements, so they are equal. (Algebraically: (A ∩ B′) ∩ (C ∩ B′) = (A ∩ C) ∩ B′.)
(b) b(n) = 5ⁿ. For any integer k ≥ 1: 5·b(k − 1) = 5·5ᵏ⁻¹ = 5ᵏ = b(k). Hence the sequence satisfies b(k) = 5·b(k − 1) for all k ≥ 1 (with b(0) = 1).
Q6
(a)
| p | q | r | p ∧ q | (p ∧ q) ∨ r | q ∨ r | p ∧ (q ∨ r) |
|---|---|---|---|---|---|---|
| T | T | T | T | T | T | T |
| T | T | F | T | T | T | T |
| T | F | T | F | T | T | T |
| T | F | F | F | F | F | F |
| F | T | T | F | T | T | F |
| F | T | F | F | F | T | F |
| F | F | T | F | T | T | F |
| F | F | F | F | F | F | F |
The last two columns differ (e.g. p = F, q = T, r = T gives T and F), so (p ∧ q) ∨ r and p ∧ (q ∨ r) are not logically equivalent.
(b) Premises p ∨ q, p → ~q, p → r; conclusion r.
| p | q | r | p ∨ q | p → ~q | p → r | r | Note |
|---|---|---|---|---|---|---|---|
| T | T | T | T | F | T | T | |
| T | T | F | T | F | F | F | |
| T | F | T | T | T | T | T | critical – r true |
| T | F | F | T | T | F | F | |
| F | T | T | T | T | T | T | critical – r true |
| F | T | F | T | T | T | F | critical – r false |
| F | F | T | F | T | T | T | |
| F | F | F | F | T | T | F |
In the critical row p = F, q = T, r = F all premises are true but the conclusion r is false. Therefore the argument form is invalid.
