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 DFAs/NFAs and Regular/Non-regular Expressions

A Regular Expression and Its Corresponding NFA

  1. Consider the regular expression ( (1 00 1*)* ) ∪ 10*.
    1. Identify two strings that are members of the language described by this regular expression.
    2. Identify two strings that are NOT members of the language described by this regular expression.
    3. Use the procedure described in Lemma 1.55 to convert the above regular expression to an NFA.

Regular and Non-regular Languages

  1. For each of the following, determine if the language is regular or not, and justify your answer in each case.
    1. Let the alphabet Σ = {0, 1, +, =} and let A be the language:
      A = {x+y=z | x, y, and z are binary unsigned integers and z is the sum of x and y}
      Is A an regular language? Justify your answer.
    2. Let the alphabet Σ = {a, b}, and let B be the strings over this alphabet with either an odd number of a's or an even number of b's, but not both an odd number of a's and an even number of b's. Is B a regular language? Justify your answer.
    3. Consider the alphabet Σ = {a, b}. For a string s ∈ Σ*, define sR as the reverse of s. That is, the characters in sR are the same as the characters in s, but the characters appear in the reverse order. Is {s sR | s ∈ Σ*} a regular language? Be sure to justify your answer.

DFA-based/Table-driven Program

  1. Recognizing Numbers Although C/C++ allow several different formats for numbers, this problem considers only two main forms.

    Notes: For this problem:

    1. Write a DFA to recognize both integers and floating-point numbers, as defined above.
      When scanning characters to identify a number, find the longest sequence of characters that can be a number.
      Thus, 123.456 should be identified as a floating-point number, not the integer 123 , following by the floating-point number .456 .
      Similarly, 123.45.6789 should be identified as the floating-point number 123.45 , followed by the floating point number .6789 .
    2. Write a regular expression to accept all strings that are either integers or floating-point numbers, as defined above.
    3. Using either the program dfa-comments.c or or the template dfa-comments-2.c as an example, write a DFA-based/table-driven program that uses your DFA of part a to identify and print all numbers read (until an end-of-file character is encountered). For each number identified, the program should label it appropriately as an integer or floating point type.

      As with all programs for this course,

      • The program must conform to the SSU CS C/C++ Style Guide (see SSU CS Department copy or Instructor's copy).
      • For this problem, submit both a listing of the C/C++ program, and a description of test runs, and the corresponding results.
      • If you use a file in testing, print and submit the contents of the file.
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.