Course Synthesis 2
Course Synthesis 2
Course Synthesis 2
Problem Points
Short Answer Questions /10
Medium Answer Questions /4
Problem #1 - Bayes’s Theorem /8
Problem #2 - Coin-Flipping Game /8
Problem #3 - Sequences and Series /8
Problem #4 - Equivalence Relations /8
Problem #5 - Euler and Hamilton /8
Problem #6 - Binary Tree Search /8
Problem #7 - Guess My Word /8
Instructions
This Synthesis will be marked out of 54. You are to answer all of the Short Answer Questions,
worth up to 10 marks, and all of the Medium Answer Questions, worth up to 4 marks. For the
seven Full Solution Problems, attempt as many of them as you wish, but only your top five will be
counted. For example, if you get 7 points on the Short Answer Questions, 3 on the Medium Answer
Questions, and your marks on the seven Full Solution Problems are 8, 0, 4, 8, 2, 7, 8, then your
grade will be 7+3+8+4+8+7+8 = 45 out of 54, since your lowest two scores will be dropped.
Think of this Synthesis as a week-long individual take-home exam where you may consult your
notes, the course textbook, anything on the Canvas Page, and any websites linked from the Canvas
Page. However, you may NOT consult your classmates or look at any other online resources unless
explicitly approved by me beforehand. Please post your questions on the Canvas Discussion Forum
if you would like any clarifications or hints.
To make it easier for the TAs, submit one .pdf file with your responses to the Short Answer
Questions, one .pdf file with your responses to the Medium Answer Questions, and then individual
.pdf files for each of the (full-solution) Problems.
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 2
Hand in a single .pdf file (ideally one page long) on which you will provide your answers to the 10 ques-
tions below.
All you need to do is submit your final ANSWERS to these 10 questions. No additional work is re-
quired or requested. No justification is required – all I want is your final answer.
Each correct answer will be worth 1 point. For each incorrect answer, the TAs will decide whether
your response will be awarded 0.5 points (for an answer that is almost correct) or 0 points.
(1) I’m thinking of a secret password containing two letters (from A to Z), followed by two digits (from
0 to 9). No letter or digit can appear more than once. Some possible passwords include AB01,
RH85, and ZA90.
(2) You roll two 6-sided die, and multiply the two numbers together.
Your answer corresponds to the amount of money you win. For example, if you roll 2 and 5,
then the product is 2 × 5 = 10. So you win $10.
Determine the expected value of the amount of money you will win by playing this game.
You can write your answer as a fraction or as a decimal (both answers are acceptable).
Here is the equivalent mathematical formulation of this problem: let X and Y be random vari-
ables for which each of the numbers {1, 2, 3, 4, 5, 6} occurs with probability 61 . Determine E[X · Y ].
(4) Let T (n) be a recurrence relation defined by T (1) = 1 and T (n) = 3T (n − 1) + 1 for all n ≥ 2.
320 −1
Let x be the integer for which T (x) = 2 = 1, 743, 392, 200.
Determine x.
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 3
(5) Let S be the set of squares on an 8 × 8 chessboard. Each element of S is an ordered pair (x, y),
where 1 ≤ x ≤ 8 is the x-coordinate and 1 ≤ y ≤ 8 is the y-coordinate.
There are numerous relations R : S → S, relating the elements of S to itself. Consider the re-
lation (x1 , y1 ) R (x2 , y2 ) ⇔ x1 · y2 = x2 · y1 . One can prove that R is an equivalence relation.
For example, squares (3, 6) and (2, 4) are related because 3 × 4 = 6 × 2 = 12.
(6) Suppose you were running Bubble Sort on the following list: [3, 8, 7, 5, 2, 6, 4]. What would the list
order be after 2 passes through the list?
(7) Let H be the set of human beings, and let N be the set of non-negative integers.
Let f : H → N be a function defined as follows: for each x ∈ H, f (x) is equal to the sum of
x’s age and the number of friends that x has on Facebook. For example, f (Alan) = 42 + 0 = 42.
(10) Suppose the running time of an algorithm is f (n) = 100n2 + 500 n · log(n).
Hand in a single .pdf file on which you will provide your answers to the 2 questions below.
Pn
(1) Using Mathematical Induction, prove the following identity. k=1 (k − 1)k = (n3 − n)/3.
(2) Given the following graph, calculate the smallest cost path from vertex A to vertex G utilizing
Dijkstra’s Algorithm, showing all steps.
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 5
A space-ship operator is having problems with imposters boarding their spaceships and disrupting the
crew. The government has developed a powerful “risk-scoring algorithm” to catch imposters before they
board a spaceship.
It is estimated that for every imposter who tries to board a spaceship, there are 100, 000 crew-members
who are perfectly safe, posing no threat to security. (In other words, the probability that any given
crew-member is an imposter is 1 in 100, 001.)
This risk-scoring algorithm is 100% sensitive, i.e., it will correctly identify an imposter 100% of the
time.
This risk-scoring algorithm is 99% specific, i.e., it will correctly allow a non-imposter to board a spaceship
99% of the time, but will incorrectly identify that crew-member as an imposter 1% of the time.
(a) Suppose a crew-member attempts to board a spaceship and is flagged by the risk-scoring algorithm
as an imposter. Alarms go off and a dozen space-police officers come and take this crew-member in
for questioning.
The officers believe that because the risk-scoring algorithm is so accurate, they are nearly 100%
certain that this crew-member is an imposter. Are they correct?
Answer this question by determining the actual probability that this crew-member is an imposter.
(b) Bayes’ Theorem enables us to calculate P (A|B), the posterior probability of event A happening,
given that event B has occurred.
In the above problem, event A is that the crew-member is an imposter, and event B is that the
crew-member has been identified as an imposter by the risk-scoring algorithm. We start with the
prior probability P (A) and then use the sensitivity and specificity probabilities to calculate P (A|B).
Suppose the prior probability is x, the sensitivity is y, and the specificity is z. In the above
1 99
problem, we have x = 100,001 , y = 1, and z = 100 .
Determine the correct formula for the posterior probability P (A|B), clearly explaining your steps.
(c) In part (a), you will have noticed that the posterior probability P (A|B) is different from the prior
probability P (A). This makes sense, since the information of event B happening allows us to update
the probability of event A happening.
Suppose our prior probability is x = P (A) = 0. Show that the posterior probability P (A|B)
remains 0 no matter what the sensitivity and specificity rates are. Explain why this makes sense.
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 6
1
You are given a fair coin, where Heads comes up with probability 2 and Tails comes up with probability 21 .
You play a game where you start with 0 points. Each time you flip Heads, you add 2 points to your
score. Each time you flip Tails, you add 1 point to your score.
If you reach a total of exactly n points, then you win. However, if you go over n points, then you
lose.
For example, suppose that n = 5. If you flip Heads, Tails, Tails, then your score is 2+1+1=4. Now
if you flip Tails, your score is 4+1=5 points and you win the game, but if you flip Heads, your score is
4+2=6 points and you lose the game.
Let Pn be the probability that you win the game with a target score of n points.
Pn−1
(a) Clearly explain why Pn = 1 − 2 for each integer n ≥ 2.
(b) Determine an explicit formula for Pn that holds for all integers n ≥ 1. Prove that your formula is
correct, either using Mathematical Induction or a direct algebraic proof.
Hint: your formula will be of the form Pn = a + b · cn , for some real numbers a, b, c.
2
(c) Suppose you are given an unfair coin where Heads comes up with probability 3 and Tails comes up
with probability 31 .
Once again, let Pn be the probability that you win the game with a target score of n points.
Consider the quadratic sequence t1 , t2 , t3 , t4 , . . ., where the first four terms are
(a) Find an explicit formula for tn , the nth term of this sequence. Clearly justify why your formula is
correct.
Determine an explicit formula for Sn , clearly showing the steps in your calculation. Simplify your
formula as much as possible.
Let S = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}.
There are numerous relations R : S → S, relating the elements of S to itself. For example, consider
the relation x R y ⇔ (x2 − y 2 ) = 0 (mod 3).
(b) Determine the total number of equivalence classes of R, clearly justifying your answer.
(c) Suppose that R : S → S is any equivalence relation (not just the one above). In other words, R is
reflexive, symmetric, and transitive.
Hint: your goal is to show that E(x) and E(y) are identical sets. One way to do this is to draw
the two-circle Venn Diagram with sets E(x) and E(y). First you show that x and y must belong
to the intersection E(x) ∩ E(y), and then you show that there cannot exist an element z ∈ S that
appears in one circle but not in the other. Convince yourself that this enables you to conclude that
E(x) ⊆ E(y) and E(y) ⊆ E(x), which implies that E(x) = E(y).
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 9
Recall that a graph is Hamiltonian if it contains at least one Hamiltonian cycle, and a graph is Eulerian
if it contains at least one Eulerian cycle.
(a) Let X be the graph on the left, with 7 vertices and 12 edges. Let Y be the graph on the right, with
7 vertices and 10 edges.
For each of X and Y , determine whether the graph is Hamiltonian, and determine whether the
graph is Eulerian. Clearly justify your answers.
(b) Consider an Eulerian path of graph Y . Clearly explain why this path must start at vertex A and
end at vertex D, or start at vertex D and end at vertex A.
(c) Each of 16 rooms has a “point value”, as indicated in the diagram below. Your task is to collect
as many points as possible. Enter at the start, exit at the finish, and pass through each room no
more than once.
Determine the maximum number of points you can collect. Clearly justify your answer.
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 10
For all positive integers k ≥ 1, vertex k has two children: 2k (Left) and 2k + 1 (Right). The first few
levels of this infinite tree are presented above.
(a) Starting with vertex 1, we can use a search algorithm to pass through the vertices in this infinite
graph. Suppose that we always go towards the vertex that has the lower number. For example,
from vertex 1, we must go to 2 instead of 3, since 2 < 3.
Will the Depth-First Search (DFS) algorithm ever reach vertex 18? If so, how? If not, explain
why not.
(b) For each positive integer n, let f (n) be the binary representation of n. For example, f (7) = 111
and f (42) = 101010.
Explain how the binary representation f (n) tells you how to generate the sequence of Left and
Right steps needed to go from vertex 1 to vertex n. Apply your explanation to n = 2024, and
confirm that your answer is the same as your sequence from Problem Set #9.
(c) Suppose you want to get from vertex 1 to vertex n, where n is a very large number. While the
Breadth-First Search (BFS) algorithm is guaranteed to eventually reach n, this search algorithm is
slow and inefficient.
Create a faster search algorithm that quickly generates the sequence of Left and Right steps needed
to go from vertex 1 to vertex n. Explain how your algorithm works for n = 2024, and determine
the running time of your algorithm (e.g. O(n2 ), O(n), O(log n), etc.).
CS5002, Fall 2024, Timothy Edmunds – Course Synthesis 2 11
https://hryanjones.com/guess-my-word/
Each time you enter a guess, the program will tell you whether the secret word is alphabetically before
your guess, alphabetically after your guess, or exactly matches your guess.
Each secret word is randomly chosen from a dictionary with exactly 267, 751 words.
(b) Suppose the secret word is randomly chosen from a dictionary with exactly 2k − 1 words, where
k is a positive integer. Clearly and carefully explain why the secret word can be determined in at
most k guesses.
(c) Suppose the website chooses a random 8-letter string of letters, between aaaaaaaa and zzzzzzzz,
as its secret word. If you play this game perfectly, you can correctly identify the 8-letter string in
at most N guesses. Determine this number N , and clearly justify why your answer is correct.