Assignment 4 (Extra Credit)
CS 270/680 Mathematical Foundations of Computer Science
Instructor: Jeremy Johnson
Due date: (Beginning of class on Nov. 16)
This is an extra credit assignment. It provides an opportunity for
students to show that they now understand some of the material that they previously
had difficulty with on earlier assignments. These questions are related
to problems done in assignment 4, the extra problems from the first midterm,
and the problem on complete binary trees that I went over in last class.
- Consider the grammar
- <Number> -> <Digit><Number>|epsilon
- <Digit> -> 0|1|2|3|4|5|6|7|8|9
Use induction to show that the number of strings in L(<Number>)
of length n is equal to 10^n.
- Recall that a binary tree can be defined recursively as
- A Binary Tree is either empty
- or A Binary Tree consists of a node with a left and right child
both of which are Binary Trees.
The degree of a node in a tree is equal to 0 if both children are empty,
1 if one of the children are empty, and 2 of both children are not empty.
Use induction to show that the number of nodes in a binary tree is equal
to one more than the sum of the degrees of the nodes in a binary tree.
- Recall that the binomial coefficient binom(n,m) = n!/(m!*(n-m)!) satisfies
the following recurrence relation (we assume that n >= m >=
0.
- binom(n,0) = 1
- binom(n,n) = 1
- binom(n,m) = binom(n-1,m) + binom(n-1,m-1) for n > m and m >
0.
- Write a recursive procedure, B(n,m), using this recurrence relation,
to compute binom(m,n)
- Recall that a tree can be used to represent recursive calls. Each
node represents a recursive call for some function F and its children
represent the calls made by F. Nodes with no children (leaf nodes)
represent the base case of the recursion. Such a tree is called a
"call tree". Derive a recurrence relation and for the number of nodes
in the call tree for the recursive procedure B(n,m).
- Use induction to show that the number of nodes in the call tree
for B(n,m) = 2*binom(m,n) - 1. Argue that the running time for B(n,m)
is O(binom(m,n)).
- Consider the grammar
- <A> -> <B><A>
- <A> -> <A><B>
- <A> -> aa<A>
- <A> -> epsilon
- <B> -> b<B>
- <B> -> a<B>a
- <B> -> epsilon
Show that the language L(<A>) is equal to all strings of a's
and b's with an even number of a's. You will need to show that every
string generated by the grammar has an even number of a's and that every
string with an even number of a's can be generated by the grammar. To
show that every string generated by the grammar has an even number of
a's, use induction on the number of rule applications. To show that every
string with an even number of a's can be generated by the grammar, use
induction on the length of the string.
How to submit
Students should submit their solution electronically. Use a word processor
(e.g. word with the equation editor or latex) to create your solution and
submit either 1) a text file, 2) a word document, or 3) a pdf file. Alternatively,
you can submit a pdf file containing a scan of a handwritten solution.
You should submit your assignment using WebCT. Also, bring a paper copy
of your homework to the class meeting when it is due.