Study resource

Read at your pace, then save it for later.

Year 2025 - DSC 102 - Computer Application

UNIT-I

1. Answer any two questions from the following: [2 × 2 = 4 Marks]

(a) Define compound proposition with example. [2 Marks]

Answer:

A compound proposition is a mathematical statement formed by combining two or more simple propositions (atomic statements) using logical connectives such as AND (∧), OR (∨), NOT (¬), IMPLIES (⇒), or IF AND ONLY IF (⇔).

Example: Let P = "It is raining" and Q = "I will take an umbrella". The statement "It is raining and I will take an umbrella" (P ∧ Q) is a compound proposition.

(b) What is well formed formula? [2 Marks]

Answer:

A Well-Formed Formula (WFF) in propositional logic is a syntactically correct string of symbols (propositional variables, logical connectives, and parentheses) constructed according to specific inductive rules:

  • Any atomic proposition variable (such as P, Q, R) is a WFF.
  • If α and β are WFFs, then (¬α), (α ∧ β), (α ∨ β), (α ⇒ β), and (α ⇔ β) are also WFFs.
  • No other expression is a WFF.

(c) Define inverse and contra-positive of any conditional statement. [2 Marks]

Answer:

For a given conditional statement P ⇒ Q (If P, then Q):

  • Inverse: The inverse is formed by negating both hypothesis and conclusion: ¬P ⇒ ¬Q ("If not P, then not Q").
  • Contrapositive: The contrapositive is formed by swapping and negating both hypothesis and conclusion: ¬Q ⇒ ¬P ("If not Q, then not P"). Note that a conditional statement is always logically equivalent to its contrapositive.

2. Answer any one question from the following: [10 Marks]

(a) (i) Determine the validity of the following argument: [5 Marks]

If I study, then I will pass.
If I do not go to a movie, then I will fail.
I will study.
Therefore, I went to a movie.

Answer:

Step 1: Formalize into Propositional Variables

  • Let S: I study
  • Let P: I will pass
  • Let M: I go to a movie

Step 2: Express Premises and Conclusion Symbolic Form

  • Premise 1: S ⇒ P
  • Premise 2: ¬M ⇒ ¬P (Equivalently, P ⇒ M by contrapositive)
  • Premise 3: S
  • Conclusion: M

Step 3: Formal Deduction (Proof of Validity)

  1. S ⇒ P (Premise 1)
  2. S (Premise 3)
  3. P (By Modus Ponens from 1 and 2)
  4. ¬M ⇒ ¬P (Premise 2)
  5. P ⇒ M (Contrapositive of Premise 2)
  6. M (By Modus Ponens from 3 and 5)

Conclusion: The argument is VALID because the conclusion M follows logically from the premises using standard rules of inference (Modus Ponens).

(a) (ii) Obtain the truth table for α = (P ∨ Q) ∧ (P ⇒ Q) ∧ (Q ⇒ P) [5 Marks]

Answer:

Let us construct the truth table step-by-step for the compound proposition α = (P ∨ Q) ∧ (P ⇒ Q) ∧ (Q ⇒ P):

PQP ∨ QP ⇒ QQ ⇒ P(P ⇒ Q) ∧ (Q ⇒ P)α = (P ∨ Q) ∧ (P ⇒ Q) ∧ (Q ⇒ P)
TTTTTTT
TFTFTFF
FTTTFFF
FFFTTTF

Analysis: The expression α evaluates to True (T) only when both P and Q are True, and evaluates to False (F) in all other cases. Thus, α is logically equivalent to P ∧ Q.

(b) (i) Prove that the following argument is valid: p → ¬q, r → q, r ⊨ ¬p [5 Marks]

Answer:

Formal Proof using Rules of Inference:

  1. r (Premise 3)
  2. r → q (Premise 2)
  3. q (Modus Ponens on lines 1 and 2)
  4. p → ¬q (Premise 1)
  5. q → ¬p (Contrapositive of line 4, since ¬(¬q) ≡ q)
  6. ¬p (Modus Ponens on lines 3 and 5)

Alternative Verification using Truth Table:

pqr¬q¬pp → ¬qr → qPremises True?Conclusion (¬p)
TTTFFFTNoF
TTFFFFTNoF
TFTTFTFNoF
TFFTFTTNoF
FTTFTTTYes (Row 5)T
FTFFTTTNo (r is F)T
FFTTTTFNoT
FFFTTTTNo (r is F)T

In all truth assignments where all premises (p → ¬q, r → q, and r) are simultaneously True (Row 5), the conclusion ¬p is also True. Hence, the argument is valid.

(b) (ii) Show that P ⇒ (Q ∨ R) and (P ⇒ Q) ∨ (P ⇒ R) are logically equivalent. [5 Marks]

Answer:

Method 1: Algebraic Proof using Logical Equivalences

We start with the Right-Hand Side (RHS):

(P ⇒ Q) ∨ (P ⇒ R)

≡ (¬P ∨ Q) ∨ (¬P ∨ R) (By implication law: A ⇒ B ≡ ¬A ∨ B)

≡ (¬P ∨ ¬P) ∨ (Q ∨ R) (By Associative and Commutative Laws)

≡ ¬P ∨ (Q ∨ R) (By Idempotent Law: ¬P ∨ ¬P ≡ ¬P)

≡ P ⇒ (Q ∨ R) (By implication law)

Since LHS ≡ RHS, the two expressions are logically equivalent.

Method 2: Truth Table Comparison

PQRQ ∨ RP ⇒ (Q ∨ R)P ⇒ QP ⇒ R(P ⇒ Q) ∨ (P ⇒ R)
TTTTTTTT
TTFTTTFT
TFTTTFTT
TFFFFFFF
FTTTTTTT
FTFTTTTT
FFTTTTTT
FFFFTTTT

Since the truth values of both columns are identical for all combinations of P, Q, and R, P ⇒ (Q ∨ R) ≡ (P ⇒ Q) ∨ (P ⇒ R).

UNIT-II

3. Answer any two questions from the following: [2 × 2 = 4 Marks]

(a) Write down the properties of binary relations. [2 Marks]

Answer:

A binary relation R on a set A can possess the following fundamental properties:

  • Reflexive: (x, x) ∈ R for all x ∈ A.
  • Symmetric: If (x, y) ∈ R, then (y, x) ∈ R.
  • Transitive: If (x, y) ∈ R and (y, z) ∈ R, then (x, z) ∈ R.
  • Antisymmetric: If (x, y) ∈ R and (y, x) ∈ R, then x = y.

(b) What is bijective function? Give an example. [2 Marks]

Answer:

A function f: A → B is called a bijective function (or one-to-one correspondence) if it is both injective (one-to-one) and surjective (onto).

Example: Let f: ℝ → ℝ be defined by f(x) = 2x + 3. Since every distinct real number maps to a distinct image (one-to-one) and every real number in the codomain has a pre-image (onto), f is bijective.

(c) What do you mean by intersection of two sets? Give example. [2 Marks]

Answer:

The intersection of two sets A and B, denoted by A ∩ B, is the set of all elements that belong to both set A and set B.

Symbolically: A ∩ B = {x : x ∈ A and x ∈ B}.

Example: If A = {1, 2, 3, 4} and B = {3, 4, 5, 6}, then A ∩ B = {3, 4}.

4. Answer any one question from the following: [10 Marks]

(a) (i) If A, B and C are any sets, then show that the following identities hold true: A - (B ∩ C) = (A - B) ∪ (A - C) and A × (B ∪ C) = (A × B) ∪ (A × C) [6 Marks]

Answer:

Part 1: Proof of A - (B ∩ C) = (A - B) ∪ (A - C)

We will show set equality by proving mutual inclusion or logical equivalences for any element x:

x ∈ A - (B ∩ C)

⇔ x ∈ A ∧ x ∉ (B ∩ C)

⇔ x ∈ A ∧ ¬(x ∈ B ∧ x ∈ C)

⇔ x ∈ A ∧ (x ∉ B ∨ x ∉ C) (By De Morgan's Law of Logic)

⇔ (x ∈ A ∧ x ∉ B) ∨ (x ∈ A ∧ x ∉ C) (By Distributive Law of Logic)

⇔ x ∈ (A - B) ∨ x ∈ (A - C)

⇔ x ∈ (A - B) ∪ (A - C)

Since all steps are bi-conditional (⇔), A - (B ∩ C) = (A - B) ∪ (A - C).

Part 2: Proof of A × (B ∪ C) = (A × B) ∪ (A × C)

Let (x, y) be an arbitrary ordered pair:

(x, y) ∈ A × (B ∪ C)

⇔ x ∈ A ∧ y ∈ (B ∪ C)

⇔ x ∈ A ∧ (y ∈ B ∨ y ∈ C)

⇔ (x ∈ A ∧ y ∈ B) ∨ (x ∈ A ∧ y ∈ C) (By Distributive Law of Logic)

⇔ (x, y) ∈ (A × B) ∨ (x, y) ∈ (A × C)

⇔ (x, y) ∈ (A × B) ∪ (A × C)

Hence, A × (B ∪ C) = (A × B) ∪ (A × C).

(a) (ii) Define reflexive and symmetric relation with example. [4 Marks]

Answer:

1. Reflexive Relation

A binary relation R on a set A is called reflexive if every element of A is related to itself. Formally, ∀ x ∈ A, (x, x) ∈ R.

Example: Let A = {1, 2, 3}. The relation R = {(1, 1), (2, 2), (3, 3), (1, 2)} is reflexive on A because (1,1), (2,2), and (3,3) are all present in R.

2. Symmetric Relation

A binary relation R on a set A is called symmetric if whenever an element x is related to y, then y is also related to x. Formally, ∀ x, y ∈ A, (x, y) ∈ R ⇒ (y, x) ∈ R.

Example: Let A = {1, 2, 3}. The relation S = {(1, 2), (2, 1), (2, 3), (3, 2)} is symmetric because for every pair (x, y), its reverse (y, x) is also present in S.

(b) (i) Consider the following three relations on the set A = {1, 2, 3}: R = {(1, 1), (1, 2), (1, 3), (3, 3)}, S = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)}, T = {(1, 1), (1, 2), (2, 2), (2, 3)}. Determine whether or not each of the above relations on A is reflexive, symmetric and transitive. [5 Marks]

Answer:

1. Relation R = {(1, 1), (1, 2), (1, 3), (3, 3)}

  • Reflexive: No, because element 2 ∈ A but (2, 2) ∉ R.
  • Symmetric: No, because (1, 2) ∈ R but (2, 1) ∉ R.
  • Transitive: Yes. Checking all pairs: (1, 1) & (1, 2) → (1, 2) ∈ R; (1, 1) & (1, 3) → (1, 3) ∈ R; (1, 3) & (3, 3) → (1, 3) ∈ R. All transitivity conditions hold.

2. Relation S = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)}

  • Reflexive: Yes, because (1, 1), (2, 2), and (3, 3) are all in S.
  • Symmetric: Yes, because (1, 2) ∈ S and (2, 1) ∈ S; all diagonal elements are self-symmetric.
  • Transitive: Yes. Testing pairs like (1, 2) and (2, 1) gives (1, 1) ∈ S, (2, 1) and (1, 2) gives (2, 2) ∈ S. (Note: S is an equivalence relation).

3. Relation T = {(1, 1), (1, 2), (2, 2), (2, 3)}

  • Reflexive: No, because (3, 3) ∉ T.
  • Symmetric: No, because (1, 2) ∈ T but (2, 1) ∉ T.
  • Transitive: No, because (1, 2) ∈ T and (2, 3) ∈ T, but (1, 3) ∉ T.

(b) (ii) Let A = {1, 2, 3}, B = {a, b, c} and C = {x, y, z}. Consider the following relations R and S from A to B and from B to C respectively: R = {(1, b), (2, a), (2, c)} and S = {(a, y), (b, x), (c, y), (c, z)}. Find the composition relation R ◦ S. Also find R². [5 Marks]

Answer:

Part 1: Composition Relation R ◦ S (S ∘ R)

The composition relation R ◦ S (or S ∘ R) from set A to set C is defined as:
R ◦ S = {(u, w) ∈ A × C : ∃ v ∈ B such that (u, v) ∈ R and (v, w) ∈ S}

Let us compute for each pair in R:

  • From (1, b) ∈ R and (b, x) ∈ S ⇒ (1, x)
  • From (2, a) ∈ R and (a, y) ∈ S ⇒ (2, y)
  • From (2, c) ∈ R and (c, y) ∈ S ⇒ (2, y)
  • From (2, c) ∈ R and (c, z) ∈ S ⇒ (2, z)

Combining all generated pairs, we get:
R ◦ S = {(1, x), (2, y), (2, z)}

Part 2: Computation of R²

The relation R is defined from set A to set B where A = {1, 2, 3} and B = {a, b, c}. Since the codomain of R (Set B) is completely disjoint from the domain of R (Set A), there exists no element v such that (u, v) ∈ R and (v, w) ∈ R.

Therefore, R² = R ◦ R = ∅ (Empty set).

UNIT-III

5. Answer any two questions from the following: [2 × 2 = 4 Marks]

(a) What is equivalence relation? [2 Marks]

Answer:

A binary relation R on a set A is called an equivalence relation if and only if it satisfies three properties simultaneously:

  • Reflexive: (x, x) ∈ R for all x ∈ A.
  • Symmetric: (x, y) ∈ R ⇒ (y, x) ∈ R for all x, y ∈ A.
  • Transitive: (x, y) ∈ R and (y, z) ∈ R ⇒ (x, z) ∈ R for all x, y, z ∈ A.

(b) What is duality principle? Give example. [2 Marks]

Answer:

The Duality Principle states that any true algebraic identity in a lattice or Boolean algebra remains valid if the operations and identity elements are interchanged as follows:

  • Swap + (OR / Join) with · (AND / Meet)
  • Swap 0 (least element) with 1 (greatest element)

Example: The dual of the identity a + 0 = a is obtained by replacing + with · and 0 with 1, yielding a · 1 = a.

(c) What do you mean by complemented lattice? [2 Marks]

Answer:

A complemented lattice is a bounded lattice L (having least element 0 and greatest element 1) in which every element a ∈ L has at least one complement a' ∈ L such that:

a ∨ a' = 1 (Join is 1) and a ∧ a' = 0 (Meet is 0).

6. Answer any one question from the following: [10 Marks]

(a) (i) In Boolean Algebra, show that (a + b)' = a' * b' [3 Marks]

Answer:

By the uniqueness of complement in Boolean Algebra, to prove that (a + b)' = a' * b', we must demonstrate that a' * b' satisfies both defining conditions of the complement of (a + b):

  1. (a + b) + (a' * b') = 1
  2. (a + b) * (a' * b') = 0

Proof of Condition 1:

(a + b) + (a' * b') = [(a + b) + a'] * [(a + b) + b'] (By Distributive Law)
= [(b + a) + a'] * [(a + b) + b'] (By Commutative Law)
= [b + (a + a')] * [a + (b + b')] (By Associative Law)
= [b + 1] * [a + 1] (Since x + x' = 1)
= 1 * 1 = 1.

Proof of Condition 2:

(a + b) * (a' * b') = (a' * b') * (a + b) (By Commutative Law)
= [(a' * b') * a] + [(a' * b') * b] (By Distributive Law)
= [(b' * a') * a] + [(a' * b') * b] (By Commutative Law)
= [b' * (a' * a)] + [a' * (b' * b)] (By Associative Law)
= [b' * 0] + [a' * 0] (Since x * x' = 0)
= 0 + 0 = 0.

Since both conditions hold, (a + b)' = a' * b' (De Morgan's First Law).

(a) (ii) Prove that (x + y)(x + z) = x + yz [3 Marks]

Answer:

Starting from the Left-Hand Side (LHS):

LHS = (x + y)(x + z)

= x · x + x · z + y · x + y · z (By Distributive Law)

= x + xz + xy + yz (Since x · x = x by Idempotent Law)

= x(1 + z) + xy + yz (By Distributive Law)

= x(1) + xy + yz (Since 1 + z = 1)

= x + xy + yz (Since x · 1 = x)

= x(1 + y) + yz (By Distributive Law)

= x(1) + yz (Since 1 + y = 1)

= x + yz = RHS.

Hence, (x + y)(x + z) = x + yz.

(a) (iii) Let a be any element of a Boolean Algebra B. Show that: (1) If a + x = 1 and a * x = 0, then x = a' (2) (a')' = a. [4 Marks]

Answer:

(1) Proof of Uniqueness of Complement:

We are given that a + x = 1 and a * x = 0. We know that a + a' = 1 and a * a' = 0.

Consider x:

x = x * 1 (Identity law)
= x * (a + a') (Since a + a' = 1)
= (x * a) + (x * a') (Distributive law)
= (a * x) + (x * a') (Commutative law)
= 0 + (x * a') (Given: a * x = 0)
= (a * a') + (x * a') (Since a * a' = 0)
= (a + x) * a' (Distributive law)
= 1 * a' (Given: a + x = 1)
= a'.

Thus, x = a'.

(2) Proof of Involution Law (a')' = a:

Let y = a'. By definition of complement:

y + y' = 1 ⇒ a' + (a')' = 1

y * y' = 0 ⇒ a' * (a')' = 0

Also for element a, we know:

a' + a = 1 (Commutative)

a' * a = 0 (Commutative)

By the uniqueness of complement proved in part (1), since both (a')' and a act as complements to a', we conclude that (a')' = a.

(b) (i) Draw the Hasse diagram of: 1. ({3, 4, 12, 24, 48, 72}, |) 2. (D_12, |) [7 Marks]

Answer:

1. Hasse Diagram of ({3, 4, 12, 24, 48, 72}, |)

The partial order is the divisibility relation a | b ("a divides b").

  • Minimal elements (Level 0): 3 and 4 (neither divides the other).
  • Level 1: 12 (since 3 | 12 and 4 | 12). Connect 3 → 12 and 4 → 12.
  • Level 2: 24 (since 12 | 24). Connect 12 → 24.
  • Maximal elements (Level 3): 48 and 72 (since 24 | 48 and 24 | 72). Connect 24 → 48 and 24 → 72.

Textual Structure of Hasse Diagram 1:

  • Top level: 48 and 72
  • Edges: (24, 48) and (24, 72)
  • Middle level 2: 24
  • Edge: (12, 24)
  • Middle level 1: 12
  • Edges: (3, 12) and (4, 12)
  • Bottom level: 3 and 4

2. Hasse Diagram of (D_12, |)

D_12 is the set of all positive divisors of 12: D_12 = {1, 2, 3, 4, 6, 12}.

  • Level 0 (Bottom): 1
  • Level 1: 2 and 3 (Edges: 1 → 2, 1 → 3)
  • Level 2: 4 and 6 (Edges: 2 → 4, 2 → 6, 3 → 6)
  • Level 3 (Top): 12 (Edges: 4 → 12, 6 → 12)

Textual Structure of Hasse Diagram 2:

  • Top level: 12
  • Edges from 4 → 12 and 6 → 12
  • Middle level: 4 and 6
  • Edges from 2 → 4, 2 → 6, 3 → 6
  • Lower level: 2 and 3
  • Edges from 1 → 2 and 1 → 3
  • Bottom level: 1

(b) (ii) Write the differences between poset and lattice. [3 Marks]

Answer:

FeaturePartially Ordered Set (Poset)Lattice
DefinitionA set equipped with a binary relation that is reflexive, antisymmetric, and transitive.A poset in which every pair of elements has a unique Least Upper Bound (LUB/Join) and Greatest Lower Bound (GLB/Meet).
LUB & GLB ExistenceLUB and GLB may or may not exist for every pair of elements.LUB (x ∨ y) and GLB (x ∧ y) MUST exist for EVERY pair of elements.
Algebraic StructureDefined purely as a relational structure (S, ≤).Can be defined both as a relational structure and as an algebraic structure (L, ∨, ∧).
Example({2, 3, 4, 6}, |) is a poset but NOT a lattice because LUB(2,3)=6 but GLB(2,3) does not exist in the set.(D_12, |) = {1, 2, 3, 4, 6, 12} is a lattice.

UNIT-IV

7. Answer any two questions from the following: [2 × 2 = 4 Marks]

(a) What is binary tree? Give an example. [2 Marks]

Answer:

A binary tree is a rooted tree structure in which every node has at most two children, referred to as the left child and the right child.

Example: A parent node A with left child B and right child C forms a binary tree with three nodes.

(b) What do you mean by Internal node and leaf node? [2 Marks]

Answer:

  • Internal Node: A node in a tree that has at least one child (non-zero degree).
  • Leaf Node (Terminal Node): A node in a tree that has no children (degree 0).

(c) Define spanning tree with an example. [2 Marks]

Answer:

A spanning tree of a connected, undirected graph G = (V, E) is a subgraph that is a tree containing all the vertices of G with the minimum number of edges (specifically, |V| - 1 edges).

Example: For a triangle graph with 3 vertices {A, B, C} and 3 edges, removing any one edge yields a path of 2 edges connecting all 3 vertices, which is a spanning tree.

8. Answer any one question from the following: [10 Marks]

(a) (i) Consider the following rooted tree (T): [Rooted tree T with root b; children of b are a, e, c; children of a are f, g; child of c is d; children of d are h, i] [5 Marks]

  • 1. Find the root of T.
  • 2. Find the terminal vertices of T.
  • 3. What are the levels of c and d?
  • 4. Find the children of c and d.
  • 5. Find the descendents of the vertices a and e.

Answer:

  1. Root of T: The vertex b.
  2. Terminal vertices (leaf nodes) of T: Vertices with no children: {f, g, e, h, i}.
  3. Levels of c and d: Taking root b at level 0:
    • Level of c = 1
    • Level of d = 2
  4. Children of c and d:
    • Children of c: {d}
    • Children of d: {h, i}
  5. Descendants of a and e:
    • Descendants of a: {f, g}
    • Descendants of e: ∅ (None, as e is a leaf node)

(a) (ii) Explain the in-order and pre-order traversal of a tree. [5 Marks]

Answer:

Tree traversal is the process of visiting all nodes in a tree data structure systematically.

1. Pre-Order Traversal (Root - Left - Right)

In a pre-order traversal, the algorithm visits nodes in the following recursive order:

  1. Visit the Root node first.
  2. Traverse the Left subtree in pre-order.
  3. Traverse the Right subtree in pre-order.

Algorithm Application: Used for creating a copy of the tree or evaluating prefix expressions.

2. In-Order Traversal (Left - Root - Right)

In an in-order traversal, the algorithm visits nodes in the following recursive order:

  1. Traverse the Left subtree in in-order.
  2. Visit the Root node.
  3. Traverse the Right subtree in in-order.

Algorithm Application: For Binary Search Trees (BST), in-order traversal visits nodes in non-decreasing sorted order.

(b) (i) What is minimum cost spanning tree? Take any suitable example to find minimum cost spanning tree. [5 Marks]

Answer:

Definition

A Minimum Cost Spanning Tree (MST) of a connected, edge-weighted undirected graph is a spanning tree whose sum of edge weights is minimized over all possible spanning trees.

Example & Solution (Kruskal's Algorithm)

Consider a weighted graph with 4 vertices {A, B, C, D} and edges:
(A,B) = 1, (B,C) = 3, (A,C) = 4, (C,D) = 2, (B,D) = 5.

Steps using Kruskal's Algorithm:

  1. Sort all edges in non-decreasing order of weights:
    • (A,B) = 1
    • (C,D) = 2
    • (B,C) = 3
    • (A,C) = 4
    • (B,D) = 5
  2. Select edges one by one, ensuring no cycle is formed:
    • Pick (A,B) [weight = 1] — No cycle.
    • Pick (C,D) [weight = 2] — No cycle.
    • Pick (B,C) [weight = 3] — No cycle. All 4 vertices {A, B, C, D} are now connected.

Minimum Total Cost: 1 + 2 + 3 = 6.

(b) (ii) 1. Find all spanning trees of the graph G shown in the figure: [Graph G with vertices a, b, c, d forming a cycle a-b-c-d-a and diagonal a-c] [3 Marks]

Answer:

The given graph G has V = 4 vertices {a, b, c, d} and E = 5 edges: E = {(a,b), (b,c), (c,d), (d,a), (a,c)}.

Any spanning tree must contain V - 1 = 3 edges and be acyclic.

The total number of spanning trees is 8. They are obtained by removing 2 edges to break cycles without disconnecting the graph:

  1. Edges: {(a,b), (b,c), (c,d)}
  2. Edges: {(a,b), (b,c), (d,a)}
  3. Edges: {(b,c), (c,d), (d,a)}
  4. Edges: {(a,b), (c,d), (d,a)}
  5. Edges: {(a,c), (a,b), (c,d)}
  6. Edges: {(a,c), (a,b), (d,a)}
  7. Edges: {(a,c), (b,c), (c,d)}
  8. Edges: {(a,c), (b,c), (d,a)}

(b) (ii) 2. Prove that the maximum number of vertices in a binary tree of height h is 2^(h+1) - 1, h ≥ 0. [2 Marks]

Answer:

In a binary tree, the maximum number of nodes at level i is 2i (where root is at level 0).

The maximum total number of vertices N in a binary tree of height h is the sum of nodes at all levels from 0 to h:

N = 20 + 21 + 22 + ... + 2h

This is a finite geometric series with first term a = 1, common ratio r = 2, and number of terms h + 1.

Using the geometric sum formula Sn = a(rn - 1) / (r - 1):

N = 1 · (2h+1 - 1) / (2 - 1) = 2h+1 - 1.

Hence proved.

UNIT-V

9. Answer any two questions from the following: [2 × 2 = 4 Marks]

(a) What is regular graph? [2 Marks]

Answer:

A regular graph is a graph where every vertex has the exact same degree. If every vertex has degree k, it is called a k-regular graph.

Example: A cycle graph C4 (a square) is a 2-regular graph because every vertex has a degree of 2.

(b) Define isomorphic graph with example. [2 Marks]

Answer:

Two graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there exists a bijection f: V1 → V2 such that two vertices u, v are adjacent in G1 if and only if f(u), f(v) are adjacent in G2.

Example: A 4-cycle graph formatted as a square and a 4-cycle formatted as a diamond are isomorphic.

(c) What is bipartite graph? [2 Marks]

Answer:

A bipartite graph is a graph whose vertex set V can be partitioned into two disjoint sets V1 and V2 such that every edge connects a vertex in V1 to a vertex in V2. No edges exist between vertices within the same set.

10. Answer any one question from the following: [10 Marks]

(a) (i) Explain Eulerian and Hamiltonian graph. Write down the difference between Eulerian and Hamiltonian graph? [5 Marks]

Answer:

1. Eulerian Graph

An Eulerian graph is a connected graph that contains an Eulerian circuit—a closed trail that visits every edge of the graph exactly once and returns to the starting vertex. A connected graph is Eulerian if and only if every vertex has an even degree.

2. Hamiltonian Graph

A Hamiltonian graph is a graph that contains a Hamiltonian cycle—a closed loop that visits every vertex of the graph exactly once (except the starting/ending vertex).

Differences Between Eulerian and Hamiltonian Graphs

FeatureEulerian GraphHamiltonian Graph
Primary FocusVisits every edge exactly once.Visits every vertex exactly once.
Necessary & Sufficient ConditionConnected graph where all vertices have even degree (Euler's Theorem).No known simple necessary and sufficient condition (NP-complete problem).
Vertex VisitsVertices may be visited multiple times.Vertices must be visited EXACTLY once.
Edge TraversalsEvery edge must be traversed.Not all edges need to be traversed.

(a) (ii) Write short notes on the following: 1. Degree of a vertex 2. Simple graph 3. Path [5 Marks]

Answer:

1. Degree of a Vertex

The degree of a vertex v in an undirected graph, denoted deg(v), is the total number of edges incident to v. A self-loop contributes 2 to the degree of a vertex. By the Handshaking Lemma, the sum of degrees of all vertices equals twice the number of edges: ∑ deg(v) = 2|E|.

2. Simple Graph

A simple graph is an unweighted, undirected graph that contains no self-loops (edges connecting a vertex to itself) and no parallel edges (multiple edges connecting the same pair of vertices).

3. Path

A path in a graph is a sequence of vertices and edges v0, e1, v1, e2, ..., ek, vk such that all vertices (and thus all edges) are distinct. The length of a path is equal to the number of edges in it.

(b) (i) What do you mean by adjacency matrix and adjacency list? Write adjacency matrix and adjacency list for the following graph: [Directed graph with 5 vertices A, B, C, D, E] [5 Marks]

Answer:

Definitions

  • Adjacency Matrix: A 2D square matrix M of size n × n (where n is the number of vertices) used to represent a graph. Entry M[i][j] = 1 if there is a directed edge from vertex i to vertex j, and 0 otherwise.
  • Adjacency List: A collection of linked lists or arrays where each vertex has a list containing all the adjacent target vertices it points to.

Example Representation

Consider a directed graph with 5 vertices V = {A, B, C, D, E} and directed edges: E = {(A,B), (A,C), (B,D), (C,D), (C,E), (D,E)}.

1. Adjacency Matrix

VertexABCDE
A01100
B00010
C00011
D00001
E00000

2. Adjacency List

  • A: → B → C
  • B: → D
  • C: → D → E
  • D: → E
  • E: → (empty)

(b) (ii) Draw the graphs corresponding to the following adjacency matrices: 1. A = [1 0 0 1; 0 0 2 1; 0 2 0 0; 1 1 0 1] 2. B = [1 3 0 0; 3 0 1 1; 0 1 2 2; 0 1 2 0] [5 Marks]

Answer:

1. Graph for Matrix A (Vertices v1, v2, v3, v4)

Matrix A is a 4 × 4 symmetric matrix representing a pseudograph/multigraph with loops:

  • v1: Has 1 self-loop; connected to v4 by 1 edge.
  • v2: Connected to v3 by 2 parallel edges; connected to v4 by 1 edge.
  • v3: Connected to v2 by 2 parallel edges.
  • v4: Has 1 self-loop; connected to v1 by 1 edge, and to v2 by 1 edge.

Graph Description 1: 4 vertices labeled {v1, v2, v3, v4}. Self-loops at v1 and v4. Double parallel edge between v2 and v3. Single edges (v1, v4) and (v2, v4).

2. Graph for Matrix B (Vertices v1, v2, v3, v4)

Matrix B is a 4 × 4 matrix representing a multigraph with loops and multiple edges:

  • v1: Has 1 self-loop; connected to v2 by 3 parallel edges.
  • v2: Connected to v1 by 3 edges, to v3 by 1 edge, and to v4 by 1 edge.
  • v3: Has 2 self-loops; connected to v2 by 1 edge, and to v4 by 2 parallel edges.
  • v4: Connected to v2 by 1 edge, and to v3 by 2 edges.

Graph Description 2: 4 vertices {v1, v2, v3, v4}. One self-loop at v1, two self-loops at v3. 3 parallel edges between v1 and v2. 2 parallel edges between v3 and v4. Single edge between v2 and v3, and single edge between v2 and v4.


xxx

Did this help you understand better?

Your feedback improves the quality of this resource for everyone.