CS 205: Introduction to Discrete Structures I
Homework 3
Due April 11 at 11:59 P.M.
Spring 2025, Sections 11, 12, and 13
Instructor: Daniel Schoepflin
([email protected])
Instructions: For this homework, you must complete all work by yourself. You are not allowed to discuss
the homework problems with others nor use online resources outside of the course materials.
Format: Homeworks will be released on Canvas and should also be turned in on Canvas in the Gradescope
as a single pdf file containing the solutions in order. Homeworks are to be typeset. Handwritten homeworks
will not be accepted.
The preferred method for typesetting your homework is to use LATEX. You can download LATEX for
free here: https://www.latex-project.org/get/. For the purpose of this course, you do not even need to
install LATEX and can instead use an online LATEX editor such as Overleaf (https://www.overleaf.com. Two
great introductory resources for LATEX are https://www.tug.org/begin.html and http://joshua.smcvt.
edu/proofs/tutorial.pdf. You can also use the wonderful tool Detexify (http://detexify.kirelabs.
org/classify.html) for finding the LATEX commands of a symbol (just draw the symbol!). If you are
interested in learning more about LATEX (beyond what is needed for this course), check the Wikibook on
LATEX (https://en.wikibooks.org/wiki/LaTeX). The course staff are also available to help you with any
question you may have in using LATEX. This policy is in place as the instructor strongly believes that
LATEX (tremendously) helps you, the student, in writing clean and well-structured proofs (a clean proof is a
necessity for a rigorous proof) as well as editing an already written proof further. Moreover, learning LATEX
is an important life-long skill that will come handy sooner or later. Additionally, grading homeworks done
in LATEX is a considerably easier (and much more pleasant) task than handwritten homeworks.
Students that turn in all their homeworks in LATEX are given a 10 point bonus credit towards their
lowest homework grade.
Regrading: All regrading requests must be made within at most one week after you received your
grades for that homework.
Late homeworks: You are allowed to submit homeworks late, by up to 48 hours past the due date and
time. If the homework is submitted late within 24 hours of the deadline a penalty of 25 points will be
deducted from the score you obtain for the homework. If the homework is submitted late between 24 and 48
hours of the deadline a penalty of 40 points will be deducted from the score you obtain. You will receive
zero points for any homework submitted after 48 hours past the deadline.
1
Problem 1. [15 points] Consider a simplified version of American football where on any possession a
team can earn 0, 3 or 7 points. What is the smallest number n0 of points such that for all n ≥ n0 and n ∈ N
a team could earn n points. You must prove that your answer is correct via induction (HINT: Don’t forget
to show that n0 is the smallest number above which any number of points is reachable).
Problem 2. [20 points] A full k-ary tree is a (rooted) tree whose nodes either have exactly k children
(internal nodes) or have no children (leaves). Using structural induction, formally prove that every full k-ary
tree that has x internal nodes has exactly kx + 1 nodes in total. Note that for full binary trees, i.e., when
k = 2, this would imply that the total number of nodes is 2x + 1.
Problem 3. [15 points] A palindrome is a string that reads the same backward as it does forward. For
example, abaaaba is a palindrome. Suppose that we need to define a language that generates palindromes.
(a) Define a phase structure grammar that generates the set of all palindromes over the alphabet {a, b}
clearly describing the recursive rules that generates palindromes. Use the notation Symbol → rule. The
empty set is denoted by λ. Clearly identify the terminal and non-terminal symbols in your grammar.
(b) Show that the palindrome abaaaba can be recognized by your grammar. To show this, show all steps
of parsing the expression abaaaba using the rules you defined above.
Problem 4. [20 points] A prefix of length ℓ of some word w are the first ℓ characters (in order) of w.
1. Construct a context-free grammar for the language:
L = {w ∈ {a, b}∗ | every prefix of w has at least as many a’s as b’s}
2. Explain why every word generated by your context-free grammar (in Part 1) is contained in L. Then,
prove via induction that every w ∈ L is produced by your context-free grammar.
Problem 5. [15 points] Consider a vocabulary consisting of the nucleotide bases V = {A, T, G, C}.
Construct a DFA to recognize strings which end in AAGT .
(a) Draw the DFA with clear markings of all states including start and acceptance state(s).
(b) Simulate the DFA to show that string T GAAGT will be accepted by the DFA.
(c) Simulate the DFA to show that string T AAGT G will not be accepted by the DFA.
Problem 6. [15 points] In this exercise, we will investigate a technique to prove that a language is not
regular. This tool is called the pumping lemma.
The pumping lemma says that if M = (S, I, f, s0 , F ) is a DFA with p states (i.e., p = |S|) and if the word
w is in L(M ) (the language generated by M ) and w has length greater than or equal to p, then w may be
divided into three pieces, w = xyz, satisfying the following conditions:
1. For each i ∈ N, xy i z ∈ L(M ).
2. |y| > 0 (i.e., y contains at least one character).
3. |xy| ≤ p (i.e., the string xy has at most p characters).
2
Use the pumping lemma to show the following language is not regular (HINT: Use proof by contradiction
to assume the language is regular and apply the pumping lemma to the language):
L = {0k 1k | k ∈ N}