Docsity

Practice Final Test - Languages and Computation | CS 3240, Exams of Computer Science

Toggle sidebar
bg1
CS 3240 : Languages and Computation
Practice T est
1. Devise a Turing M achine that accepts a language L = {0i # 0j
, where i is a squ are
of j}, E xamp le : ~000000000#000~, here the fi rst number (9) is a squ are of the
second one (3) and th us the language is ac ce pted.
Show the complete input as well as tape alphabet, the algorithm and the complete
state machine for full credit.
2. Show a T M for recogn izing the language L = { w#wR} show ing the tape format,
algorithm and the complete state machineZİ
3. D evise a non-deterministic pushdown automata fo r the fol low ing C F G and show
the parse using t he input :
S Æ a A b | b B a
A Æ a B b | c
B Æ b A a | c
4. For the fol low ing gram ma r answer the questions
(a) Compute First(), Follow() for each non-terminal and also compute the
Predict() sets for each production
(b) Is this grammar LL(1)? Why or why not?
© If it is not LL(1), convert it into LL(1) and then show LL(1) parsing table
or show LL(2) parsing table without converting it.
<assign-statement> Æ ID = <exp> ;
<assign-statement> Æ ID (<param-list>);
<assign-statement> Æ ID ++;
<assign-statement> Æ ID [ <index> ] = <exp>;
<exp> Æ CONST
<param-list> Æ ID <param-tail>
<param-tail> Æ , ID <param-tail>
<param-tail> Æ İ
4 Pr ove or dispr ove wh eth er the fol low ing la ngu ages ar e regular by either
showing D FA /N FA o r th rough pumping lemma respect iv ely
a. L = {0m , m is a perfect cube of some integer, m > 0}
b. L = { 05n, n > 0, alphabet = {0}}
c. L is a language made from alphabet {a, b, c} in which a, b or c appear in
any order and the totaOQXPEHURIF¶VLVHTXDOWRWZLFHWKHVXPRIWKH
QXPEHURID¶VDQG E¶V
5. T he iterative algorithm w e discussed in the class to compu te the F irst() an d
Follow() sets is inefficient; suggest an impr ovement to com pu te the sets more
eff iciently. H in t: Consid er putting an o rder on t he computation of sets.

Partial preview of the text

Download Practice Final Test - Languages and Computation | CS 3240 and more Exams Computer Science in PDF only on Docsity!

CS 3240 : L anguages and Computation

Practice T est

  1. Devise a T uring M achine that accepts a language L = {0 i^ # 0 j^ , where i is a square of j }, E xample : ~000000000#000~, here the first number (9) is a square of the second one (3) and thus the language is accepted. Show the complete input as well as tape alphabet, the algorithm and the complete state machine for full credit.

  2. Show a T M for recognizing the language L = { w#w R^ } showing the tape format, algorithm and the complete state machine Zİ 

  3. Devise a non-deterministic pushdown automata for the following C F G and show the parse using the input : S Æ a A b | b B a A Æ a B b | c B Æ b A a | c

  4. For the following grammar answer the questions (a) Compute First(), Follow() for each non-terminal and also compute the Predict() sets for each production (b) Is this grammar LL(1)? Why or why not? © If it is not LL(1), convert it into LL(1) and then show LL(1) parsing table or show LL(2) parsing table without converting it. <assign-statement> Æ ID = ; <assign-statement> Æ ID (<param-list>); <assign-statement> Æ ID ++; <assign-statement> Æ ID [ ] = ; Æ CONST <param-list> Æ ID <param-tail> <param-tail> Æ , ID <param-tail> <param-tail> Æ İ 4 Prove or disprove whether the following languages are regular by either showing D F A/N F A or through pumping lemma respectively a. L = {0m^ , m is a perfect cube of some integer, m > 0} b. L = { 0 5n^ , n > 0, alphabet = {0}} c. L is a language made from alphabet {a, b, c} in which a, b or c appear in any order and the totaOQXPEHURIF¶VLVHTXDOWRWZLFHWKHVXPRIWKH QXPEHURID¶VDQG E¶V

  5. T he iterative algorithm we discussed in the class to compute the First() and Follow() sets is inefficient; suggest an improvement to compute the sets more efficiently. H int: Consider putting an order on the computation of sets.