(3 pts) (3 pts)
(3 pts) (3 pts)
(3 pts)
(3 pts)
(2 pts)
(2.5 pts) (2.5 pts)
CS 181 FINAL EXAM WINTER 2020
You have 3 hours to complete this exam. You may state without proof any fact taught in class or assigned as homework. Your algorithms must terminate on all inputs.
1 Construct one-tape, deterministic Turing machines that decide the languages below. You must provide both a state-transition diagram and a detailed verbal description:
a. binary strings of the form (0n1)k, where n ¡Ý 0 and k ¡Ý 0;
b. binary strings (including ¦Å) that represent properly nested parentheses, where 0
denotes an open parenthesis and 1 denotes a close parenthesis.
2 Give an algorithm that takes as input a DFA D and determines whether D accepts at least two palindromes.
3 A language L is called downward-closed if for every string w that L contains, L also contains every prefix of w. Give an algorithm that takes as input a regular expression R and decides whether the language that R generates is downward-closed.
4 A variable T in a context-free grammar G is called essential if every derivation of every string by G uses the variable T. Give an algorithm that takes as input a context-free grammar G and a variable T, and decides whether T is essential in G.
5 A string w is said to cover a given PDA P if there is a computation by P on w such that every state of P is visited. Give an algorithm that takes as input a PDA P and decides whether there is a string that covers P.
6 Prove that every infinite decidable language can be partitioned into two disjoint infinite decidable languages.
7 For each problem below, determine whether it is decidable and prove your answer:
a. on input a Turing machine M and a symbol ¦Ò, decide whether M ever writes ¦Ò on
the tape in any computation;
b. on input a Turing machine M, decide if M recognizes a decidable language.