Discrete Structure, Past Papers, UOS Main Campus

Discrete Structure Past Paper 2014 – BS IT 3rd Term UOS (CMP-200)

ProgramBS IT
Term3rd
Year2014
Course codeCMP-200
AnswersSolved ✓

University of Sargodha BS IT 3rd term Discrete Structure (CMP-200) paper, 2014 exam, session 2012-16 (80 marks, 2:30 hours). The paper is retyped below without the handwritten notes, followed by solved answers for all 16 short questions and all subjective questions: writing propositions, Boolean simplification, induction for 2n > n³, tracing factorial(6), counting and the pigeonhole principle, graphs, set laws and fundamental circuits. Logic answers were checked with SymPy.

Solved answers

Q1 – Short answers (16 × 2)

I. Proposition vs predicate logic. A proposition is a statement that is either true or false, e.g. “5 > 3”. Propositional logic combines such statements with connectives. Predicate logic uses predicates with variables and quantifiers, e.g. P(x): “x > 3” – its truth depends on x, and ∀x P(x) or ∃x P(x) become propositions.

II. Implication, hypothesis, conclusion. The implication p → q means “if p then q”; it is false only when p is true and q is false. p is the hypothesis (premise) and q is the conclusion. Example: “If it rains (hypothesis), then the ground is wet (conclusion).”

III. Converse and contrapositive. p: we have an exam; q: there will be no tornado warning. Converse (q → p): “If there is no tornado warning, then we have an exam.” Contrapositive (¬q → ¬p): “If there is a tornado warning, then we do not have an exam.”

IV. 11000 ∧ (01011 ∨ 11011). 01011 ∨ 11011 = 11011; then 11000 ∧ 11011 = 11000.

V. Surjective vs injective. Injective (one-to-one): different inputs give different outputs, f(a) = f(b) ⇒ a = b; e.g. f(x) = 2x on integers. Surjective (onto): every element of the codomain is an image; e.g. f(x) = x − 1 on integers. f(x) = x² on integers is neither.

VI. Members of the sets. a. {−2, 2}.   b. ∅ (no integer squares to 2, since √2 is irrational).

VII. Logical expression. Let r: “Berries are ripe along the trail”, g: “Grizzly bears have been seen in the sea”. The statement is r ∧ ¬g (“but” means “and”).

VIII. Truth of conditionals. a. 1 + 1 = 2 is true and 2 + 2 = 5 is false, so T → F is false. b. 1 + 1 = 3 is false, so F → F is true.

IX. Rows in truth tables. Rows = 2n for n distinct variables. a. (r ∧ ¬r): one variable → 2 rows. b. (r ∧ p) ∧ (s ∧ ¬r): r, p, s → 8 rows.

X. Is (¬p ∧ (p → q)) → ¬q a tautology? No. Take p = F, q = T: ¬p = T, p → q = T, so the hypothesis is T, but ¬q = F, so the implication is F. One false row means it is not a tautology. (Checked with SymPy.)

XI. (p → q) ∧ (q → p) ≡ p ↔ q.

pqp→qq→p(p→q)∧(q→p)p↔q
TTTTTT
TFFTFF
FTTFFF
FFTTTT
The last two columns are identical, so they are logically equivalent.

XII. Universal vs existential quantifier. ∀x P(x) (“for all x”) is true only if P(x) is true for every x in the domain. ∃x P(x) (“there exists x”) is true if P(x) is true for at least one x. Example over integers: ∀x (x + 0 = x) is true; ∃x (x² = 4) is true (x = 2).

XIII. Binary search tree. Insert in order: the, quick, brown, fox, jumps, over, (the – duplicate, ignored), lazy, dog.

              the
             /
         quick
         /
      brown
          \
          fox
         /   \
       dog   jumps
                \
                over
                /
             lazy

XIV. Truth values over integers. a. ∀n (n² ≥ 0) is true – every square is non-negative. b. ∃n (n² = 2) is false – no integer has square 2.

XV. Bipartite graph. A graph whose vertices can be split into two disjoint sets V1, V2 so that every edge joins a vertex of V1 to a vertex of V2. Example: C4 with V1 = {a, c}, V2 = {b, d}; K2,3. (A triangle is not bipartite.)

XVI. Pigeonhole principle. If k + 1 or more objects are placed in k boxes, at least one box contains two or more objects (generalised: at least ⌈N/k⌉). Example: among 13 people at least two were born in the same month.

Q2 (a) – Propositions with p and q

p: It is below freezing.   q: It is snowing.

  1. It is below freezing but not snowing: p ∧ ¬q
  2. It is either below freezing or snowing: p ∨ q
  3. It is either below freezing or snowing, but it is not snowing if it is below freezing: (p ∨ q) ∧ (p → ¬q)
  4. That it is below freezing is necessary and sufficient for it to be snowing: p ↔ q
  5. It is not below freezing and it is not snowing: ¬p ∧ ¬q
  6. It is below freezing but it is not snowing: p ∧ ¬q

Q2 (b) – Simplify XY + XZ + YZ + YZW

YZ + YZW = YZ(1 + W) = YZ (absorption). So the expression = XY + XZ + YZ. No further reduction is possible (checked with SymPy simplify_logic); it is the 2-out-of-3 majority function.

Q3 (a) – Induction: 2n > n³ for n > 9

Basis (n = 10): 210 = 1024 > 10³ = 1000. ✓

Inductive step: assume 2k > k³ for some k ≥ 10. Then 2k+1 = 2·2k > 2k³. We need 2k³ ≥ (k + 1)³, i.e. (1 + 1/k)³ ≤ 2. For k ≥ 10, (1 + 1/k)³ ≤ 1.1³ = 1.331 < 2. Hence 2k+1 > 2k³ ≥ (k + 1)³.

By mathematical induction, 2n > n³ for every integer n > 9.

Q3 (b) – Trace factorial(6)

factorial(6) = 6 * factorial(5)      call
factorial(5) = 5 * factorial(4)      call
factorial(4) = 4 * factorial(3)      call
factorial(3) = 3 * factorial(2)      call
factorial(2) = 2 * factorial(1)      call
factorial(1) = 1 * factorial(0)      call
factorial(0) = 1                     base case (n = 0)
factorial(1) = 1 * 1   = 1           return
factorial(2) = 2 * 1   = 2           return
factorial(3) = 3 * 2   = 6           return
factorial(4) = 4 * 6   = 24          return
factorial(5) = 5 * 24  = 120         return
factorial(6) = 6 * 120 = 720         result

There are 7 calls (n = 6 down to 0); the output is 720.

Q4 – Counting

(a) The first city is fixed. The other seven cities can be visited in any order: P(7, 7) = 7! = 5040 possible orders.

(b) Five grades are the boxes. By the generalised pigeonhole principle we need the smallest N with ⌈N/5⌉ ≥ 6, i.e. N = 5 × 5 + 1 = 26 students. (With 25 students each grade could have exactly 5.)

Q5 – Graphs

A graph G = (V, E) is a set of vertices V and a set of edges E, where each edge joins two vertices. Example: V = {a, b, c}, E = {ab, bc}.

  • Complete graph Kn: a simple graph in which every pair of distinct vertices is joined by exactly one edge; it has n(n − 1)/2 edges. Example: K4 on {a, b, c, d} has 6 edges ab, ac, ad, bc, bd, cd.
  • Regular graph: every vertex has the same degree k (k-regular). Example: the cycle C5 is 2-regular; K4 is 3-regular; the cube graph Q3 is 3-regular.
  • Euler path: a path that uses every edge exactly once. A connected graph has an Euler path iff it has exactly 0 or 2 vertices of odd degree (0 → Euler circuit; 2 → the path starts and ends at the odd vertices). Example: graph with edges ab, bc, cd, da, ac: deg(a) = 3, deg(c) = 3, others 2 → Euler path a–b–c–d–a–c.
K4:  a---b        C5 (2-regular):   a---b
     |\ /|                          /     \
     | X |                         e       c
     |/ \|                          \     /
     d---c                             d

Q6 – Laws of operations on sets

Set operations (∪, ∩, complement, difference) obey algebraic laws, used to simplify set expressions. For sets A, B, C in universe U:

LawUnion formIntersection form
IdentityA ∪ ∅ = AA ∩ U = A
DominationA ∪ U = UA ∩ ∅ = ∅
IdempotentA ∪ A = AA ∩ A = A
CommutativeA ∪ B = B ∪ AA ∩ B = B ∩ A
AssociativeA ∪ (B ∪ C) = (A ∪ B) ∪ CA ∩ (B ∩ C) = (A ∩ B) ∩ C
DistributiveA ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
De Morgan(A ∪ B)′ = A′ ∩ B′(A ∩ B)′ = A′ ∪ B′
AbsorptionA ∪ (A ∩ B) = AA ∩ (A ∪ B) = A
ComplementA ∪ A′ = UA ∩ A′ = ∅

Example (De Morgan): U = {1,…,6}, A = {1,2,3}, B = {3,4}. A ∪ B = {1,2,3,4}, so (A ∪ B)′ = {5,6}; A′ = {4,5,6}, B′ = {1,2,5,6}, A′ ∩ B′ = {5,6}. ✓

Q7 – Spanning tree and fundamental circuits

A spanning tree of a connected graph G is a subgraph that is a tree (connected, no cycles) and contains all vertices of G. If G has n vertices, the spanning tree has n − 1 edges. It can be found with DFS, BFS, or Kruskal/Prim for minimum weight.

Edges of G in the spanning tree T are branches; the remaining edges are chords. With e edges there are e − n + 1 chords.

Fundamental circuits: adding any one chord to T creates exactly one cycle (because T already has a unique path between the chord’s end vertices). That cycle is the fundamental circuit of the chord. Procedure:

  1. Find a spanning tree T of G.
  2. List the chords (edges of G not in T).
  3. For each chord (u, v), take the unique path from u to v in T and add the chord – this is one fundamental circuit.
  4. The e − n + 1 fundamental circuits form a basis: every cycle of G can be formed from them.

Example: G with vertices a, b, c, d and edges ab, bc, cd, da, ac (n = 4, e = 5). Spanning tree T = {ab, bc, cd}. Chords: da and ac (5 − 4 + 1 = 2). Fundamental circuits: chord da → a–b–c–d–a; chord ac → a–b–c–a.

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.