Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSC 2259 Final Exam Review, Study notes of Discrete Structures and Graph Theory

Review for final exam. Included past lecture notes.

Typology: Study notes

2024/2025

Uploaded on 02/23/2025

dylan-stokes
dylan-stokes 🇺🇸

1 document

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
“GERALD” LÊ @ 2024 – PAGE 1
CSC 2259 STUDY GUIDE FOR FINAL EXAM with LINTA ISLAM
9.1 Relations and Their Properties
- Value satisfy the relation or not:
- Reflexive Relations: When the pairs are the same (a,a)
EXAMPLE: Consider the following relations on {1, 2, 3, 4}:
R1 = {(1,1), (1,2), (1,4), (2,1), (2,2), (3,3), (4,1), (4,4)},
R2 = {(1,1), (1,2), (1, 3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4)},
R3 = {(1,1), (1,2), (2, 1)},
R4 = {(3,4)}.
Which of these relations are reflexive?
Solution:
R1 and 2 are reflexive because for each order pair of (a,b), there is also a pair of (a,a)
R3 and 5 are not reflexive because R3 is missing (2,2) as there is an (a,b) pair of (2,1)
- Symmetric Relations: if a pair in the array is (a,b) then the array must also have an (b,a) pair
- Anti-Symmetric Relations: is there is an (a,b) pair, the array SHOULD NOT have (b,a) pair in
the array. But (a,a) and (b,b) does not matter if it is in the array or not
EXAMPLE: Consider the following relations on {1, 2, 3, 4}:
R1 = {(1,1), (1,2), (2, 1)}
R2 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4,4)},
R3 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},
R4 = {(1,1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},
R5 = {(3,4)}.
R1 and R2 is Symmetric because every (a,b) pair, there is a (b,a) pair
R3, R4, R5 are asymmetric since there are a (a,b) pair, THERE WON’T be a (b,a) pair
VINICIUS JR. DESERVED THE 2024 BALLON D’OR. RODRI WINNING WAS DAYLIGHT ROBBERY.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download CSC 2259 Final Exam Review and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!

CSC 2259 STUDY GUIDE FOR FINAL EXAM with LINTA ISLAM 9.1 Relations and Their Properties

  • Value satisfy the relation or not: - Reflexive Relations : When the pairs are the same (a,a) EXAMPLE: Consider the following relations on {1, 2, 3, 4}: R1 = {(1,1), (1,2), (1,4), (2,1), (2,2), (3,3), (4,1), (4,4)}, R2 = {(1,1), (1,2), (1, 3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4)}, R3 = {(1,1), (1,2), (2, 1)}, R4 = {(3,4)}. Which of these relations are reflexive? Solution: R1 and 2 are reflexive because for each order pair of (a,b), there is also a pair of (a,a) R3 and 5 are not reflexive because R3 is missing (2,2) as there is an (a,b) pair of (2,1) - Symmetric Relations : if a pair in the array is (a,b) then the array must also have an (b,a) pair - Anti-Symmetric Relations : is there is an (a,b) pair, the array SHOULD NOT have (b,a) pair in the array. But (a,a) and (b,b) does not matter if it is in the array or not EXAMPLE: Consider the following relations on {1, 2, 3, 4}: R1 = {(1,1), (1,2), (2, 1)} R2 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4,4)}, R3 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}, R4 = {(1,1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}, R5 = {(3,4)}. R1 and R2 is Symmetric because every (a,b) pair, there is a (b,a) pair R3, R4, R5 are asymmetric since there are a (a,b) pair, THERE WON’T be a (b,a) pair

- Transitive Relations: when there is a (a,c) and (c,b) pair, their must be a (a,b) pair EXAMPLE: Consider the following relations on {1, 2, 3, 4}: R1 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}, R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)}, R3 = {(3, 4)}. R4 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)}, NOT Transitive R5 = {(1, 1), (1, 2), (2, 1)}, NOT Transitive R6 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)}, NOT Transitive R1, R2, and R3 are transitive. Ex. In R1 (3,2) and (2,1) are the (a,c) and (c,b) pair, so there must be an (a,b) pair in the array which is (3,1) - Combining Relations: Given two relations R1 and R2, we can combine them using basic set operations to form new relations such as R1 ∪ R2, R1 ∩ R2, R1 - R2, and R2 - R1. Ex. R1 = {(1,1), (2,2), (3,3)} and R2 = {(1,1), (1,2), (1,3), (1,4)} R1 ∪ R2 = {(1,1), (1,2), (1,3), (1,4), (2,2), (3,3)} - Combine R1 and R R1 ∩R2 = {(1,1)} – Common element is left R1 - R2 = {(2,2), (3,3)} – remainder of R1 that is not a common element with R R2 - R1 = {(1,2), (1,3), (1,4)} – remainder of R2 that is not a common element of R

10.2 GRAPH TERMINOLOGY AND SPECIAL TYPES OF GRAPHS

Degrees and Neighborhoods of Vertices:Adjacent/Neighbors – neighbor of the vertex (lines connected to the vertex). The edges  Undirected graphs degree – a graph without arrows, also when finding the degree, it will be the number of edges it has  Directed Graph Outdegree – arrow pointing outward, each arrow pointing outward of the vertex is consider 1 outdegree  Directed Graph Indegree – arrow pointing inward, arrow pointing toward the vertex is considered 1 indegree Example: What are the degrees and neighborhoods of the vertices in the graphs G and H? Solution: G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1, deg(e) = 3, deg(g) = 0. N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d) = {c}, N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = NULL H: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, deg(d) = 5. N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b}, N(d) = {a, b, e}, N(e) = {a, b ,d}. (N is for neighbors)

Degrees of Vertices Theorem 1 (Handshaking Theorem): If G = (V,E) is an undirected graph with m edges, then

2m =  v  V deg(v)

Proof: Each edge contributes twice to the degree count of all vertices. Hence, both the left- hand and right-hand sides of this equation equal twice the number of edges. Think about the graph where vertices represent the people at a party and an edge connects two people who have shaken hands. Example 1: How many edges are there in a graph with 10 vertices of degree 6? Solution: Because the sum of the degrees of the vertices is 6  10 = 60, the handshaking theorem tells us that 2m = 60. So the number of edges m = 30. Example 2: If a graph has 5 vertices, can each vertex have degree 3? Solution: This is not possible by the handshaking theorem, because the sum of the degrees of the vertices 3  5 = 15 is odd. Theorem 2: An undirected graph has an even number of vertices of odd degree. Proof: Let V1 be the vertices of even degree and V2 be the vertices of odd degree in an undirected graph G = (V, E) with m edges. Then

Even -> 2m =  v  V deg(v) =  v  V1 deg(v) +  v  V2 deg(v)

Explanation: deg(v) must be even, since deg(v) is even for each v  V1, and V2. This sum must be even because 2m is even and the sum of the degrees of the vertices of even degrees is also even. Because this is the sum of the degrees of all vertices of odd degree in the graph, there must be an even number of such vertices. Directed Graphs:

  • in-degree of a vertex v, denoted deg −(v)
  • out-degree of v, denoted deg+(v) Example : In the graph G, we have: deg¯(a) = 2, deg¯(b) = 2, deg¯(c) = 3, deg¯(d) = 2, deg¯(e) = 3, deg¯(f) = 0. deg⁺(a) = 4, deg⁺(b) = 1, deg⁺(c) = 2, deg⁺(d) = 2, deg⁺(e) = 3, deg⁺(f) = 0.

Bipartitie Graphs Definition: no edges which connect two vertices in V₁ or in V₂. It is not hard to show that an equivalent definition of a bipartite graph is a graph where it is possible to color the vertices red or blue so that no two adjacent vertices are the same color. G is bipartite, (a is not connected to another red like b or d) H is not bipartite since if we color a red, then the adjacent vertices f and b must both be blue. Example: Show that C₆ is bipartite. Solution: We can partition the vertex set into V₁ = {v₁, v₃, v₅} and V₂ = {v₂, v₄, v₆} so that every edge of C₆ connects a vertex in V₁ and V₂. Example: Show that C₃ is not bipartite. Solution: If we divide the vertex set of C₃ into two nonempty sets, one of the two must contain two vertices. But in C₃ every vertex is connected to every other vertex. Therefore, the two vertices in the same partition are connected. Hence, C₃ is not bipartite.

Complete Bipartite Graphs Definition: A complete bipartite graph Km,n is a graph that has its vertex set partitioned into two subsets V₁ of size m and V₂ of size n such that there is an edge from every vertex in V₁ to every vertex in V₂. Example: We display four complete bipartite graphs here. 10.3 Representing Graphs and Graph Isomorphism Adjacency List: An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of the graph. Example: Example: TABLE 1: An Adjacency List for a Simple Graph. Vertex Adjacent Vertices a b, c, e b a c a, d, e d e, c e a, c, d TABLE 2: An Adjacency List for a Directed Graph. Vertex Terminal Vertices a b, c, d, e b b, d c a, c, e d e b, c, d

Adjacency Matrices: Adjacency matrices can also be used to represent graphs with loops and multiple edges. When multiple edges connect the same pair of vertices vᵢ and vⱼ (or if multiple loops are present at the same vertex), the (i, j)-th entry equals the number of edges connecting the pair of vertices. Example: We give the adjacency matrix of the pseudograph shown here using the ordering of vertices a, b, c, d. (Basically each column and row is a,b,c,d) Adjacency matrices can also be used to represent directed graphs. Incidence Matrices: Let G = (V, E) be an undirected graph with vertices where v₁, v₂, ..., vₙ and edges e₁, e₂, ..., eₘ. The incidence matrix with respect to the ordering of V and E is the n × m matrix M = [mᵢⱼ], where mᵢⱼ = 1 when edge eⱼ is incident with vᵢ 0 otherwise.

Isomorphism of Graphs : The simple graphs G₁ = (V₁, E₁) and G₂ = (V₂, E₂) are isomorphic if there is a one-to-one and onto function f from V₁ to V₂ with the property that a and b are adjacent in G₁ if and only if f(a) and f(b) are adjacent in G₂, for all a and b in V₁. Such a function f is called an isomorphism. Two simple graphs that are not isomorphic are called nonisomorphic. General Rules for Solving Isomorphism Problems : For two graphs to be isomorphic the must meet the following requirements

  1. Both have the same number of vertices
  2. Both must have the same number of edges
  3. Both have the same degrees. Ex: {2, 2, 3, 3, 4} and {4, 2, 3, 3, 2} have the same degrees
  4. Those degrees must connect to the other degrees in same way Using the same ex from Rule 3. If the vertex of Graph A with deg(a) = 4 connects to the deg(b) = 2, deg(c) = 2, deg(d) = 3, and deg(e) = 3, then it is expected of Graph B to mimic that pattern. Example: Show that the graphs G = (V, E) and H = (W, F) are isomorphic. Solution: The function f with f(u₁) = v₁, f(u₂) = v₄, f(u₃) = v₃, and f(u₄) = v₂ is a one-to-one correspondence between V and W. Note that adjacent vertices in G are u₁ and u₂, u₁ and u₃, u₂ and u₄, and u₃ and u₄. Each of the pairs f(u₁) = v₁ and f(u₂) = v₄, f(u₁) = v₁ and f(u₃) = v₃, f(u₂) = v₄ and f(u₄) = v₂, and f(u₃) = v₃ and f(u₄) = v₂ consists of two adjacent vertices in H.

Example: Determine whether these two graphs are isomorphic. Solution: IT is Isomorphic Both graphs have six vertices and seven edges. They also both have four vertices of degree two and two of degree three. We define an injection f from the vertices of G to the vertices of H that preserves the degree of vertices. We will determine whether it is an isomorphism. The function f with f(u₁) = v₆, f(u₂) = v₃, f(u₃) = v₄, and f(u₄) = v₅, f(u₅) = v₁, and f(u₆) = v₂ is a one-to-one correspondence between G and H. Showing that this correspondence preserves edges is straightforward, so we will omit the details here. Because f is an isomorphism, it follows that G and H are isomorphic graphs.

10.5 Euler Graph, Euler Paths and Circuits Euler Paths (all vertex degrees = odd) and Circuits (all vertex degrees = even) Definition: Euler circuit: in a graph G is a simple circuit reaching every edge just once and must start and end at the same vertex. All vertices in the graph must have am even degree Euler Path : visit every edge once but does not have to end with the same vertex. Exactly two vertices in the graph must have an odd degree Example: Which of the undirected graphs G₁, G₂, and G₃ has an Euler circuit? Of those that do not, which has an Euler path? Solution: G₁ has an Euler circuit (Find the degree of every vertices, if all vertices is even then it is a Euler circuit) G2 is neither circuit nor path because the vertices are not even, and for path there need to be only 2 vertices that is an odd degree, in here a,b,d,c which are ore then 2 odd vertices degree G₃ has an Euler path (a,b are the only vertices that has an odd degree and the rest is even which cause this graph to be a path). Theorem: A graph will have a Euler path if it contains at most 2 vertices of odd degree. A graph will have a Euler circuit if all vertices have an even degree. Example: Two of the vertices in the multigraph model of the Kӧnigsberg bridge problem have odd degree. Hence, there is no Euler circuit in this multigraph and it is impossible to start at a given point, cross each bridge exactly once, and return to the starting point.

Forest: A forest is a graph that has no simple circuit, but is not connected. Each of the connected components in a forest is a tree. Theorem: An undirected graph is a tree if and only if there is a unique simple path between any two of its vertices. Proof: Assume that T is a tree. Then T is connected with no simple circuits. Hence, if x and y are distinct vertices of T, there is a simple path between them (by Theorem 1 of Section 10.4). This path must be unique - for if there were a second path, there would be a simple circuit in T (by Exercise 59 of Section 10.4). Hence, there is a unique simple path between any two vertices of a tree. Now assume that there is a unique simple path between any two vertices of a graph T. Then T is connected because there is a path between any two of its vertices. Furthermore, T can have no simple circuits since if there were a simple circuit, there would be two paths between some two vertices. Hence, a graph with a unique simple path between any two vertices is a tree. Rooted Trees: A rooted tree is a tree in which one vertex is dubbed the “root” and every edge is directed away from the root. An unrooted tree is converted into different rooted trees when different vertices are chosen as the root.

Terminologies:

  • If v is a vertex of a rooted tree other than the root, the parent of v is the unique vertex u such that there is a directed edge from u to v.
  • When u is a parent of v, v is called a child of u.
  • Vertices with the same parent are called siblings.
  • The ancestors of a vertex are the vertices in the path from the root to this vertex, excluding the vertex itself and including the root.
  • The descendants of a vertex v are those vertices that have v as an ancestor.
  • A vertex of a rooted tree with no children is called a leaf.
  • Vertices that have children are called internal vertices.
  • If a is a vertex in a tree, the subtree with a as its root is the subgraph of the tree consisting of a and its descendants and all edges incident to these descendants. Example: In the rooted tree T (with root a): (i) Find the parent of c, the children of g, the siblings of h, the ancestors of e, and the descendants of b. (ii) Find all internal vertices and all leaves. (iii) (iii) What is the subtree rooted at G? Solution: (i) The parent of c is b. The children of g are h, i, and j. The siblings of h are i and j. The ancestors of e are c, b, and a. The descendants of b are c, d, and e. (ii) (ii) The internal vertices are a, b, c, g, h, and j. The leaves are d, e, f, i, k, l, and m. (iii)

Solution: I. The left child of d is f and the right child is g. II. The left and right subtrees of c are displayed in (b) and (c). Properties of Trees Theorem 2: A tree with n vertices has n −1 edges. Proof (by mathematical induction): Don’t think this will be on test

  • BASIS STEP: When n = 1, a tree with one vertex has no edges. Hence, the theorem holds when n = 1.
  • INDUCTIVE STEP: Assume that every tree with k vertices has k −1 edges.
  • Suppose that a tree T has k + 1 vertices and that v is a leaf of T. Let w be the parent of v. Removing the vertex v and the edge connecting w to v produces a tree T′ with k vertices. By the inductive hypothesis, T′ has k −1 edges. Because T has one more edge than T′, we see that T has k edges. This completes the inductive step.

Counting Vertices in Full m-Ary Trees Theorem 3: A full m-ary tree with i internal vertices has n = mi + 1 vertices. Proof: Every vertex, except the root, is the child of an internal vertex. Because each of the i internal vertices has m children, there are mi vertices in the tree other than the root. Hence, the tree contains n = mi + 1 vertices. Theorem 4: A full m-ary tree with I. n vertices has i = (n − 1)/m internal vertices and l = [(m −1)n + 1]/m leaves, II. i internal vertices has n = mi + 1 vertices and l = (m −1)i + 1 leaves, III. l leaves has n = (ml − 1)/(m − 1) vertices and i = (l − 1)/ (m −1) internal vertices. Proof (of part I): Solving for i in n = mi + 1 (from Theorem 3) gives i = (n −1)/m. Since each vertex is l either a leaf or an internal vertex, n = l + i. By solving for l and using the formula for i, we see that l = n - i = n - (n - 1)/m = [(m - 1)n + 1]/m. (part II, III proofs left as practice) Level of Vertices and Height of Trees When working with trees, we often want to have rooted trees where the subtrees at each vertex contain paths of approximately the same length. To make this idea precise, we need some definitions:

  • The level of a vertex v in a rooted tree is the length of the unique path from the root to this vertex.
  • The height of a rooted tree is the maximum of the levels of the vertices. Example: I. Find the level of each vertex in the tree to the right. II. What is the height of the tree? Solution: I. The root a is at level 0. Vertices b, j, and k are at level 1. Vertices c, e, f, and l are at level 2. Vertices d, g, i, m, and n are at level 3. Vertex h is at level 4. II. The height is 4, since 4 is the largest level of any vertex. Balanced m-Ary Trees: A rooted m-ary tree of height h is balanced if all leaves are at levels h or h −1. Example: Which of the rooted trees shown below is balanced?