Problem Set 9
Problem Set 9
Problem Set #9
This Problem Set is due at 11:59 pm Pacific time on 2024-12-05, and will be submitted on Canvas.
This Problem Set is worth 6% of the final course grade. There are five problems.
Problems #1 and #2 and #3 are to be completed individually, while Problems #4 and #5 are to
be completed in your assigned small groups.
Please type (or neatly handwrite) your solutions on standard 8.5 × 11 (or A4) paper, with your name(s)
at the top of each solution. Ensure that you submit five separate PDF files on Canvas, one for each
problem. Make sure you label your Problem Set #1 submissions appropriately - e.g. timothy-1-1.pdf,
timothy-1-2.pdf, timothy-1-3.pdf, timothy-1-4.pdf, timothy-1-5.pdf.
Given that the last two problems are done in a group, your final two PDF files will be identical to
some of your classmates. (For example, timothy-4.pdf might be identical to yvonne1-4.pdf and bethany1-
4.pdf). This is completely fine, and enables you to have a record of all of your submitted work in this
course.
While a solution must be absolutely perfect to receive full marks, I will be generous in awarding partial
marks for incomplete solutions that demonstrate progress.
So that there is no ambiguity, there are two non-negotiable rules. A violation of either rule constitutes
plagiarism and will result in you receiving an F for this course.
(a) If you meet with a classmate to discuss one of the Problems, the articulation of your thought process
(i.e., what you submit to me), must be an individual activity, done in your own words, away from
others. Please remember that the solution-writing process is where so much of your learning will
occur in this course - even more than the time you spend on solving the problems. Do not be
surprised if it takes you 3 to 5 times as long to write up a solution as it takes you to actually solve
the problem.
(b) This Problem Set has been designed to be challenging, because struggling through problems is how
we learn best. When stuck on a problem, it can be helpful to get a small hint that will allow you to
make some progress without robbing you of the opportunity to solve the problem. Online searches,
and even well-intentioned classmates, may be unable to provide you with just a small insight. If
you need support/a small hint, the best plan is to post your query on the Canvas discussion forum.
I will be readily available during office hours, or by appointment.
CS 5002, Spring 2024 Semester, Timothy Edmunds – Problem Set #9 2
Problem #1 – INDIVIDUAL
Define Kn to be the graph on n vertices, where each pair of vertices is connected by an edge. Kn is
known as the complete graph on n vertices.
(a) Draw the complete graph K10 , and determine the total number of edges in this graph. Briefly
explain how you calculated this total.
(c) A group of Align students meet on campus to have an end-of-semester celebration party. Each pair
of students shakes hands.
Unfortunately, Paul walks in late. As a result, Paul is only able to shake hands with some of
the other students at the celebration party.
If there are exactly 42 handshakes in total, determine the number of hands that Paul shook. Clearly
and carefully justify your answer.
CS 5002, Spring 2024 Semester, Timothy Edmunds – Problem Set #9 3
Problem #2 – INDIVIDUAL
Consider this binary tree, where each vertex is labelled with a positive integer. The root vertex is 1.
For all positive integers k ≥ 1, vertex k has two children: 2k (Left) and 2k + 1 (Right).
(a) Starting with vertex 1, we can use a search algorithm to pass through all of the vertices in this
graph. Whenever we have more than one option, we always pick the vertex that has the lower
number. For example, from the vertex 1, we go to 2 instead of 3, since 2 < 3.
In your own words, describe how Breadth-First Search (BFS) and Depth-First Search (DFS) work.
Does one search algorithm always reach the destination faster than the other? Explain.
(b) Suppose we want to determine a path from vertex 1 (start vertex) to vertex 10 (end vertex).
Using BFS, determine the order in which the vertices will be visited. Using DFS, determine the
order in which the vertices will be visited. Briefly explain your answers.
(c) Suppose that we extend this binary tree to infinitely many levels, so that each vertex k has two
children: 2k (Left) and 2k + 1 (Right).
The path from vertex 1 to vertex 10 can be described by a sequence of Left and Right moves,
namely Left, Right, Left.
Consider the path from vertex 1 to vertex 2024. Determine the sequence of Left and Right moves
for this path. Clearly justify your answer.
CS 5002, Spring 2024 Semester, Timothy Edmunds – Problem Set #9 4
Problem #3 – INDIVIDUAL
Some Align students are very competitive. So one day after class, n players decided to organize a Table
Tennis tournament, where each player had one game against every other player (i.e., “round-robin”).
The results of each tournament can be represented using a directed tournament graph, where we draw an
edge from vertex i to vertex j if and only if player i lost to player j in the tournament.
From the above graph, we see that Player 1 lost two games (against Players 2 and 4), and won one game
(against Player 3).
For each player i, let wi be the number of games they won. This number is identical to the in-degree of
vertex i in the tournament graph. So in the above tournament, we have (w1 , w2 , w3 , w4 ) = (1, 2, 1, 2).
n n(n−1)
Convince yourself that in every tournament graph, we must have w1 + w2 + . . . + wn = 2 = 2 .
(a) Let n = 7. Construct a tournament graph for which (w1 , w2 , w3 , w4 , w5 , w6 , w7 ) = (6, 5, 4, 3, 2, 1, 0).
Briefly explain how you constructed your graph.
(b) Let n = 7. Construct a tournament graph for which (w1 , w2 , w3 , w4 , w5 , w6 , w7 ) = (3, 3, 3, 3, 3, 3, 3).
Briefly explain how you constructed your graph.
Determine all integers n ≥ 2 for which there exists a tournament graph for which (w1 , w2 , . . . , wn ) =
(k, k, . . . , k) for some integer k. In other words, such a tournament has the property that every
player wins exactly the same number of games.
(d) (OPTIONAL BONUS) In the above tournament with four players, 1 → 4 → 3 → 2 forms a
Hamiltonian path. In other words, there exists a path through the n vertices in the tournament
graph, where the ith player lost to the (i + 1)th player, for each 1 ≤ i < n.
Problem #4 – GROUP
Let G be a graph (not directed), and let AG be the adjacency matrix of the graph.
0 1 0 0 1
1 0 1 0 0
For example, if G is the 5-cycle above, then the adjacency matrix is AG = 0 1 0 1 0 .
0 0 1 0 1
1 0 0 1 0
(a) Define the main diagonal of an n by n adjacency matrix to be the n elements from the top-left
corner to the bottom-right corner.
For any graph G (undirected), clearly explain why the entries in the main diagonal of AG are
0, and why the entries of AG are symmetric about the main diagonal.
We define matrix multiplication as follows: let C = AB be the product of the matrices A and
B. Let ci,j be the entry in row i and column j of matrix C. Then,
0 1 0 0 1 0 1 0 0 1
1 0 1 0 0
1 0 1 0 0
Determine the matrix product 0 1 0 1 0 0 1 0 1 0 . Show your calculations.
0 0 1 0 1 0 0 1 0 1
1 0 0 1 0 1 0 0 1 0
(c) Let G be a graph, and let AG be its adjacency matrix. Let C be the matrix product C = AG AG ,
and let ci,j be the entry in row i and column j of matrix C. Clearly explain why ci,j is equal to the
number of walks of length 2 between vertex i and vertex j in graph G.
(d) (OPTIONAL BONUS) Let R be a relation, and let M = BuildM atrix(R, n) be the n×n matrix
from the previous Problem Set. Using the matrix M and the matrix product M · M , determine a
simple way to check whether R is transitive. Clearly and carefully justify your answer.
CS 5002, Spring 2024 Semester, Timothy Edmunds – Problem Set #9 6
Problem #5 – GROUP
We say that a graph G is bipartite if its vertices can be partitioned into two sets X and Y so that every
edge in G connects a vertex in X to a vertex in Y . If no such partition exists, then we say that G is not
bipartite.
We say that a graph G contains an odd cycle if there exists some set of distinct vertices v1 , v2 , . . . , v2k+1 ,
with k ≥ 1, for which the following edges appear in the graph: {v1 v2 , v2 v3 , . . . , v2k v2k+1 , v2k+1 v1 }.
As an example, the above graph contains numerous odd cycles. A 5-cycle is a − b − c − d − e − a, and a
9-cycle is a − b − c − d − i − f − h − j − e − a.
(b) Let G be a graph that contains at least one odd cycle. Clearly explain why this graph G must be
not bipartite.
(c) Let G be a graph that does not contain any odd cycles. Clearly explain why this graph G must be
bipartite.
Using the results of (b) and (c), you have now established this key result: graph G is bipartite if
and only if G does not contain an odd cycle.