Discrete Mathematics Exam Notes
Section A: Very Short Answer Questions
Question 1: Distributive Lattice
Concept: In a distributive lattice , if an element has a complement, that complement is unique.
Explanation:
A distributive lattice is one where the distributive laws hold:
If an element in a lattice has a complement , then and , where 0 and 1 are the least and greatest elements of the lattice, respectively. To prove uniqueness, assume has two complements, and . Then,
Using the distributive property, one can show that , thus proving the complement is unique.
Question 2: Logic Gates
Concept: Logic gates are basic building blocks of digital circuits that perform logical operations on one or more inputs to produce a single output.
Types of Logic Gates:
- AND Gate: The output is true (1) if and only if all inputs are true (1). Symbol:
- OR Gate: The output is true (1) if at least one input is true (1). Symbol:
- NOT Gate: The output is the inverse of the input. If the input is true (1), the output is false (0), and vice versa. Symbol:
- NAND Gate: The output is the inverse of the AND gate. It is false (0) if and only if all inputs are true (1).
- NOR Gate: The output is the inverse of the OR gate. It is true (1) if and only if all inputs are false (0).
- XOR Gate: (Exclusive OR) The output is true (1) if the inputs are different.
- XNOR Gate: (Exclusive NOR) The output is true (1) if the inputs are the same.
Question 2 OR: Simple Graph Edges
Theorem: The maximum number of edges in a simple graph with vertices is .
Proof:
In a simple graph, each vertex can be connected to every other vertex. Therefore, each of the vertices can be connected to a maximum of other vertices. This gives a total of potential connections. However, since each edge connects two vertices, we have counted each edge twice. Therefore, the maximum number of edges is .
Question 2 OR: Types of Trees
Concept: A tree is a connected graph with no cycles.
Types of Trees:
- Binary Tree: A tree in which each node has at most two children, referred to as the left child and the right child.
- Full Binary Tree: A binary tree in which every node other than the leaves has two children, and all leaves are at the same level.
- Complete Binary Tree: A binary tree in which every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible.
- Spanning Tree: A subgraph of a graph which is a tree and connects all the vertices of the original graph.
- Rooted Tree: A tree in which one node has been designated as the root.
- Decision Tree: A tree where each internal node represents a test on an attribute, each branch represents an outcome of the test, and each leaf node represents a class label (used in machine learning and decision-making).
Question 3: Recurrence Relations
Concept: A recurrence relation is an equation that defines a sequence recursively. Each term of the sequence is defined as a function of the preceding terms.
Example:
Fibonacci sequence: , with initial conditions and . The sequence starts as 0, 1, 1, 2, 3, 5, 8, …
Another example: , with . This generates the sequence 1, 3, 7, 15, …
Question 3 OR: Switching Circuit
Function:
Switching Circuit:
This function can be represented by a switching circuit with switches , , and . The term represents a parallel connection of switches and . The term represents a parallel connection of the complement of switch and a series connection of switches and the complement of switch .
Section B: Short Answer Questions
Question 1: Recurrence Relation
Recurrence Relation:
, with initial conditions and .
Solution:
Homogeneous Solution:
The characteristic equation for the homogeneous part is . This factors to , so is a repeated root. The homogeneous solution is .Particular Solution:
Since the right-hand side is a constant, we guess a constant particular solution . Substituting into the original equation, we get , which simplifies to , so .General Solution:
The general solution is .Apply Initial Conditions:
- , so .
- , so . Substituting , we get , which gives , so , and .
Final Solution:
Question 1 OR: Incidence and Adjacency Matrix
Graph: A graph with vertices and edges .
Incidence Matrix:
The incidence matrix is a matrix where if vertex is incident to edge , and 0 otherwise.
I = \begin{bmatrix}
1 & 1 & 0 & 0 & 0 \
1 & 0 & 1 & 1 & 0 \
0 & 1 & 1 & 0 & 1 \
0 & 0 & 0 & 1 & 1
\end{bmatrix}
Adjacency Matrix:
The adjacency matrix is a matrix where if there is an edge between vertices and , and 0 otherwise. Since the graph is undirected, the adjacency matrix is symmetric.
A = \begin{bmatrix}
0 & 1 & 1 & 0 \
1 & 0 & 1 & 1 \
1 & 1 & 0 & 1 \
0 & 1 & 1 & 0
\end{bmatrix}
Question 2: Equivalence Relation
Concept: A relation on a set is an equivalence relation if it is reflexive, symmetric, and transitive.
Relation: "is equal to" () on the set of all real numbers .
Proof:
- Reflexive: For all , . Therefore, the relation is reflexive.
- Symmetric: For all , if , then . Therefore, the relation is symmetric.
- Transitive: For all , if and , then . Therefore, the relation is transitive.
Since the relation "is equal to" is reflexive, symmetric, and transitive, it is an equivalence relation.
Question 2 OR: Minimal Boolean Functions
Theorem: The number of minimal Boolean functions in variables is .
Explanation:
A minimal Boolean function is a Boolean function that cannot be simplified further. A Boolean function in n variables can be represented by a truth table with rows. However, each minimal Boolean function is defined by minterms. There are minterms, and each minimal boolean function takes one of these minterms as input. This means the number of minimal boolean functions will be 2 to the power of the number of combinations of minterms, so the result is .
Question 3: Poset and Lattice
Given: and the divisibility relation on .
Poset:
To show that is a poset, we need to show that the divisibility relation is reflexive, antisymmetric, and transitive.
- Reflexive: For all , . (2|2, 3|3, 4|4, 6|6). So, reflexive.
- Antisymmetric: For all , if and , then . (If divides and divides , then must equal ). So, antisymmetric.
- Transitive: For all , if and , then . (If divides and divides , then divides ). For example, 2|4 and 4|4 implies 2|4. SO, transitive.
Since the divisibility relation is reflexive, antisymmetric, and transitive, is a poset.
Not a Lattice:
To be a lattice, every pair of elements must have a least upper bound (LUB) and a greatest lower bound (GLB).
Consider the elements 3 and 4 in . The divisors of 3 are {3} and the divisors of 4 are {2, 4}, while the multiples of 3 from the set are {3, 6} and the multiples of 4 from the set is {4}. The only divisors that it has in common is {}, meaning, the GLB (or meet) from 3 and 4 doesn't exist given the set . Therefore, is not a lattice.
Question 3 OR: Graph with Two Odd Vertices
Theorem: If a graph has exactly two odd vertices, there must be a path joining these two vertices.
Explanation:
Let be a graph with exactly two odd vertices, say and . Assume, for the sake of contradiction, that there is no path between and . Then, and must belong to different connected components, say and , respectively. Consider the connected component containing vertex . Since is an odd vertex, the sum of the degrees of the vertices in is odd. However, the Handshaking Lemma states that the sum of the degrees of the vertices in any graph is equal to twice the number of edges, which must be even. This is a contradiction. Therefore, our assumption that there is no path between and must be false. Hence, there must be a path joining these two vertices.
Question 4: Hamiltonian and Eulerian Circuits
Hamiltonian Circuit: A cycle that visits each vertex exactly once.
Eulerian Circuit: A cycle that visits each edge exactly once.
Graph with Hamiltonian Circuit but not Eulerian Circuit:
A complete graph with five vertices () has a Hamiltonian circuit (any cycle that visits all 5 vertices). However, each vertex has degree 4, so if we add one more vertex and connect it to 2 vertices, we will have an Eulerian circuit.Graph with Eulerian Circuit but not Hamiltonian Circuit:
Consider a graph with two cycles connected by a single vertex; both cycles use different edges but connect on a center vertex . For example, two triangles that share a vertex. If we added another triangle and connected it to vertex , we will still have an Eulerian circuit at vertex , but not visit all vertices.
Question 4 OR: Tree with n Vertices
Theorem: A tree with vertices has edges.
Proof:
We can use induction on the number of vertices .
Base Case: For , a tree with one vertex has 0 edges. Thus, the theorem holds.
Inductive Step: Assume the theorem holds for a tree with vertices, i.e., it has edges. Now, consider a tree with vertices. A tree is a connected graph with no cycles. If we remove a leaf (a vertex with degree 1) from the tree, we are left with a tree with vertices, which, by the inductive hypothesis, has edges. The removed leaf was connected to the rest of the tree by exactly one edge. Therefore, the original tree with vertices had edges.
Thus, the theorem holds for vertices. By the principle of mathematical induction, a tree with vertices has edges.
Section C: Long Answer Questions
Question 1: Generating Functions
Recurrence Relation: , with and .
Solution:
Define Generating Function: Let be the generating function for the sequence .
Apply Generating Function to Recurrence Relation:
Rewrite Summations:
Substitute Initial Conditions:
Solve for Y(x):
Partial Fraction Decomposition:
- Let : , so
- Let : , so
Thus,
Expand as Power Series:
Find :
Question 1 OR: Normal Forms
Function:
Conjunctive Normal Form (CNF):
Apply De Morgan's Law:
Distribute:
Apply X + X' = 1
Simplify:
Since the solution is the function 1, the CNF (or DNF) is simply 1.
Disjunctive Normal Form (DNF):
Following the same steps as above, the simplified DNF is also be 1.
Question 2: Dijkstra's Algorithm
Graph: A weighted graph with vertices a, b, c, d, e, and z.
Dijkstra's Algorithm:
Initialization:
- Distance to source (a) is 0: . Distance to all other vertices is infinity: .
- Unvisited set:
Iteration:
- a:
- Visit neighbors: b (3), c (14)
- Update distances: .
- b:
- Visit neighbors: a, c (5), d (8)
- Update distances: .
- c:
- Visit neighbors: a, b, d (4), e (13)
- Update distances: .
- d:
- Visit neighbors: b, c, e, z (10)
- Update distances: (Note: this update doesn't change the current value of d(e)), since d(d) + 8 = 19 > 11. .
- e
- Visit neighbors: c, d, z (9)
- Update distances:
- z:
- No unvisited neighbors.
- a:
Shortest Path: a -> b -> d -> z. Total distance: 3 + 8 + 10 = 21.
Answer:
The shortest path from a to z is a -> b -> d -> z with a total distance of 21.
Question 2 OR: Kruskal's and Prim's Algorithms
Graph: A weighted graph with vertices v1, v2, v3, v4, v5, and v6.
Kruskal's Algorithm:
Sort Edges: Sort all edges in increasing order of weight.
Iterate: Add edges to the spanning tree in order, unless adding an edge creates a cycle.
Edges (Weight): (v1, v2, 1), (v4, v6, 2), (v1, v5, 3), (v3, v4, 3), (v2, v4, 5), (v2, v3, 6), (v5, v6, 6), (v3, v5, 10)
Minimal Spanning Tree:
- (v1, v2, 1)
- (v4, v6, 2)
- (v1, v5, 3)
- (v3, v4, 3)
- (v2, v4, 5)
The minimal spanning tree consists of the edges (v1, v2), (v4, v6), (v1, v5), (v3, v4). The total weight is 1+2+3+3+5.
Prim's Algorithm:
Start Vertex: Choose any vertex as the starting vertex (e.g., v1).
Iterate: Grow the tree by adding the minimum weight edge that connects a vertex in the tree to a vertex not yet in the tree.
- Start: v1
- Edges from v1: (v1, v2, 1), (v1, v5, 3)
- Add (v1, v2, 1): Tree = {v1, v2}
- Edges from v1, v2: (v1, v5, 3), (v2, v3, 6), (v2, v4, 5)
- Add (v1, v5, 3): Tree = {v1, v2, v5}
- Edges from v1, v2, v5:
- (v2, v3, 6), (v2, v4, 5), (v5, v6, 6), remove v5 to v1 since that is a cycle.
*Add (v2,v4, 5): Tree={v1,v2,v5,v4}
- Edges from (v1, v2, v5,v4): (v4, V3,3) (v4,V6,2) and remove others sine are cycles. add v4, v6 since vertex has 2 unit value, then add Vertex V4 unit 3 to complete.
The minimal spanning tree consists of the edges (v1, v2), (v4, v6), (v1, v5), (v3, v4). Total weight is 1+3+2+3.
- Edges from (v1, v2, v5,v4): (v4, V3,3) (v4,V6,2) and remove others sine are cycles. add v4, v6 since vertex has 2 unit value, then add Vertex V4 unit 3 to complete.