DF CS 454: Theory of Computation
CS 454, Section 001 Sonoma State University Spring, 2026
 
Theory of Computation
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College

Although much of this course has been well developed in recent semesters, some details may be adjusted from semester to semester. For example, the Signature Project for this course has satisfied SSU's Upper Division GE Area B Requirement for CS Majors for several years, and satisfying that requirement again this semester. However, details of this project likely vary from instructor to instructor and from semester to semester. Also,

Assignment on Proofs, DFAs, and NFAs

  1. Prove:
    12 + 22 + ... + n2 = n(n+1)(2n+1) / 6
    for all positive integers n.
  2. Definition: The height of a non-empty tree is defined as the number of nodes on the longest path from a leaf of a tree to its root; the height of an empty tree is defined to be 0.

    Nodes in a Binary Tree: Suppose a binary tree T has height h. Prove that T contains at least h nodes and at most 2h - 1 nodes.

    Observation: When a conclusion has two parts, a proof might include one argument for the two parts together, or a proof might be in two separate/independent pieces (one for each part).

  3. For each of the following, construct a state diagram (DFA) for the specified language over the alphabet Σ = {a, b}.

    1. All strings containing exactly two b's (and any number of a's).
    2. All strings in which every b is followed by exactly three a's. (Note the empty string is allowed here, as are strings with just a's.)
    3. All strings that are either all a's or all b's. (note the empty string is not allowed here.)
    4. All strings that contain exactly three a's and two b's.

    Note: Any DFA must have transitions from each state for every character in the alphabet Σ. Just showing transitions for accepted strings is not adquate.

  4. Non-negative binary integers divisible by 4 (decimal) [100 (binary)]: Consider the binary representation of non-negative integers that are divisible by 4. These numbers have the following properties:

    Since the problem involves binary numbers, the relevant alphabet is Σ = {0, 1},

    1. Draw a DFA (state diagram) with no more than 12 states that accepts exactly these non-negative binary integers that are divisible by 4.
    2. Draw an NFA (state diagram) with no more than 8 states that accepts exactly these integers. (For this part, the NFA must not also be a DFA.)

    For each automaton, be sure all transitions are clearly identified and all states are clearly specified as accepting or not.

  5. Comments in C/C++: C/C++ allows two types of comments:

    For the purposes of this problem, suppose all characters within a C/C++ program are from the set Σ = {/, *, a, b, N, E}, where N represents the end-of-line character and E represents the end-of-file character. (In a real C/C++ program, of course, the characters a, b would be extended to all letters, digits, punctuation, etc., but that seems too extensive for this exercise.)

    Notes:

    Exercise: Draw an NFA state diagram with no more than 12 states that accepts exactly "programs" in which all comments are correctly specified in C/C++ and rejects any "program" that does not have the proper comment structure.

created Fall, 2023
revised Fall, 2023
revised October, 2025
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.
ccbyncsa.png

Copyright © 2011-2026 by Henry M. Walker.
Selected materials copyright by Marge Coahran, Samuel A. Rebelsky, John David Stone, and Henry Walker and used by permission.
This page and other materials developed for this course are under development.
This and all laboratory exercises for this course are licensed under a Creative Commons Attribution-NonCommercial-Share Alike 4.0 International License.