Sergio A. Alvarez web: http://www.cs.wpi.edu/ alvarez/
Department of Computer Science e-mail: alvarez@cs.wpi.edu
Worcester Polytechnic Institute phone: (508) 831-5118
Worcester, MA 01609, USA fax: (508) 831-5776

### CS 3133, A Term 1998 Final Exam Practice Problems

(also see the practice problems for the midterm exam)

1. For each of the following pairs of languages over the alphabet , determine whether or . If , give a regular expression for the languages. If , give a string w that belongs to one of the two languages but not the other.
1. all strings not having the substring .
2. all strings that contain twice as many 1's as 0's , . Note that contains the empty string.
2. Let L be the language of all strings w over the alphabet such that , where denotes the number of times that the symbol x appears in w. For example, the string abaca is in L but aabc is not.
1. Design an extended PDA (multiple pops and pushes allowed in a single transition) that accepts L by final state and empty stack.
2. Convert your extended PDA from part (a) into a standard PDA (only a single pop/push allowed in each transition).
3. Is L a regular language? Explain.
4. Is L a context-free language? Explain.
1. Find the language L accepted by the PDA P that has state set , accepting state set , input alphabet , stack alphabet , and transition function defined by

2. Design a Turing machine that accepts the language L from part (a).
3. Calculate the time complexity of the machine M from part (b).

3. Show that each of the following problems belongs to the class NP by finding a deterministic polynomial time verifier. In each case, explain what the input to the verifier is, how the verifier operates, and why it runs in polynomial time.
1. The Hamiltonian path problem: Given a graph G, determine (yes/no answer) if there is a path in G that visits each vertex of G exactly once.
2. The graph coloring problem: Given a graph G and a natural number k, determine (yes/no answer) if there is a coloring of the vertices of G using k colors such that no edge of G connects two vertices of the same color. Assume that there is at most one edge connecting any given pair of vertices.