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.

  1. Consider the grammar
  2. Use induction to show that the number of strings in L(<Number>) of length n is equal to 10^n.
  3. Recall that a binary tree can be defined recursively as
  4. 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.
  5. Recall that the binomial coefficient binom(n,m) = n!/(m!*(n-m)!) satisfies the following recurrence relation (we assume that n >= m >= 0. 
    1. Write a recursive procedure, B(n,m), using this recurrence relation, to compute binom(m,n)
    2. 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).
    3. 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)).
  6. Consider the grammar
  7. 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.