Theory of Computation Sample Final., Exercises of Theory of Computation

Theory of Computation. Sample Final. This exam is closed book. Answer all questions. 1. (10 points.) Give a regular expression for the following language A.

Typology: Exercises

2022/2023

Uploaded on 05/11/2023

courtneyxxx
courtneyxxx 🇺🇸

4.5

(14)

253 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Theory of Computation
Sample Final.
This exam is closed book. Answer all questions.
1. (10 points.) Give a regular expression for the following language A.
A={uv |u, v {a, b, c}, u, v 6=, and uand vhave no character in common}.
e.g. abc A,cacbb A,abcabc /A,abab /A.
2. (10 points.) Give a DFA or NFA to accept the following language B.
B={w|w {0,1}and wincludes a 1 but not as its third character}.
3. (10 points.) a. State the Pumping Lemma for regular languages.
b. Show that the following language Cis not regular.
C={wcuwRv|w, u, v {a, b}}.
4. (10 points.) Give a context free grammar to generate language Cfrom Problem
3b.
5. (10 points.) a. State the Pumping Lemma for context free languages.
b. Show that the following language Dis not context free.
D={aibajbakbal|i=kand j=l}.
6. (10 points.) Give a PDA to accept the following language E.
E={x1#x2#· · · #xk|k2, xh {a, b},1hk, and xi=xR
jfor some i < j}.
7. (10 points.) Let L={G|Gis a CNF grammar with no useless variables},
where a useless variable is one that is not used in any derivation of a string of variables.
Give an algorithm to show that Lis decidable. That is, give an algorithm that takes
as input a CNF grammar Gand determines whether for each variable Vin Gthere
is some derivation of a string of terminals or the empty string that uses the variable
V.
Hint: A useful first step is to determine those variables that can derive a string of
terminals or the empty string.
8. (10 points.) Suppose that you are given an algorithm AFto decide the following
language F:
F={hPi | Phalts on at least one input}.
Using AFas a subroutine, give an algorithm AAPr og to decide AP rog . Recall that
AP rog ={hP, w i | Phalts on input w}.
pf2

Partial preview of the text

Download Theory of Computation Sample Final. and more Exercises Theory of Computation in PDF only on Docsity!

Theory of Computation Sample Final.

This exam is closed book. Answer all questions.

  1. (10 points.) Give a regular expression for the following language A.

A = {uv | u, v ∈ {a, b, c}∗, u, v 6 = , and u and v have no character in common}.

e.g. abc ∈ A, cacbb ∈ A, abcabc /∈ A, abab /∈ A.

  1. (10 points.) Give a DFA or NFA to accept the following language B.

B = {w | w ∈ { 0 , 1 }∗^ and w includes a 1 but not as its third character}.

  1. (10 points.) a. State the Pumping Lemma for regular languages.

b. Show that the following language C is not regular.

C = {wcuwRv | w, u, v ∈ {a, b}∗}.

  1. (10 points.) Give a context free grammar to generate language C from Problem 3b.
  2. (10 points.) a. State the Pumping Lemma for context free languages.

b. Show that the following language D is not context free.

D = {aibaj^ bakbal^ | i = k and j = l}.

  1. (10 points.) Give a PDA to accept the following language E.

E = {x 1 #x 2 # · · · #xk | k ≥ 2 , xh ∈ {a, b}∗, 1 ≤ h ≤ k, and xi = xRj for some i < j}.

  1. (10 points.) Let L = {G | G is a CNF grammar with no useless variables}, where a useless variable is one that is not used in any derivation of a string of variables. Give an algorithm to show that L is decidable. That is, give an algorithm that takes as input a CNF grammar G and determines whether for each variable V in G there is some derivation of a string of terminals or the empty string that uses the variable V. Hint: A useful first step is to determine those variables that can derive a string of terminals or the empty string.
  2. (10 points.) Suppose that you are given an algorithm AF to decide the following language F : F = {〈P 〉 | P halts on at least one input}.

Using AF as a subroutine, give an algorithm AAP rog to decide AP rog. Recall that AP rog = {〈P, w〉 | P halts on input w}.

  1. (10 points.) Let Half-Clique be the following problem. Input: An undirected graph G = (V, E). Question: Does G have a clique of size n/2, where n = |V |?

Show that Clique ≤P Half-Clique.

Recall that clique is the following problem: Input: (H, k), where H = (W, F ) is an undirected graph and k is an integer. Question: Does G have a clique of size k?