You are on page 1of 58
CONTENTS 1, Regular Languages & Finite Automata 321 | 2. Transient and Steady State Response 22:30 3. Recursive, Recursively Enumerable Languages & Turing Machines 31-34 Computational Complexity-PNF, NP-hard, NP-complete Section B: Compiler Design Regular Languages & Finite Automata IFS = (aa, aba, baa} Which of the following strigs oS? (ay (6) abaabapaa ts Assume E =a, List a—O +. DFA accepting nothing How many states are there inthe minimum state faacceptingabove language? fa) 2 )3 e4 ies NFAaccopting everything \Which ofthe folowing isnota regular expression for aboive language? fa) aat(bb'a (6) ala + bb*ayt (©) afa+bya+a (d) fas an = bb's) DFAaccepting everthing 5, NFAaccepting“e"only 6. DFAaccepting“e“anly 3+ —_THEORTOF COMPUTATION worumadeeasyia rare ‘How mary states are there in a minimum state 14 Which ofthe folowing is false? (a) 2-dfe'shave same pawer as dias {b) 2edie'saccept regular sets (©) The ciass of 2-cfals are equivatentto ctass of nfas but niet equivalent to the class of dia’s (d) 2-cla'shave less power compared toPDA ‘fa. accepting L = {ba, baa} (aa (0) 5 (7 (as 10, The number of statesinaririmum gta io accept stings in which the total number of as is odd and total number of b's is not divisible by alts @5 m6 ts 9 11, The minimurn state dfa equivalegs transition diagram given MADE EASY ively that 8 (@ 101001, ent of a given binary oe Bid 2 given ebove are Mealy. oa machines respertvl ta (@) carrots determined : produce 2s complement of a given binary ‘The string “101001” is (@) accepted by abeveata 16. The machine given belowis + (@hrejected by above dia (©) nether aocepted nor rejected (2) not accepted since the dla goes into an in fire loop wher: processing above ving | 4 + THEORY OF COMPUTATION ‘wwwunodeeasyin av (a) A Moalymachine to find 2's complement of ‘000 + 1)" ES 8 given binary number read from least H+ 1)" 4 significant bit (LSB) (0 + Ayr (©) A Mooremachine totind 2 complement af 110 1 SA 8 given binary number read from least u significant bit (LSB) Which of the following is true? (c) AMealymachine to fine 2 complement of (a) LIR, +R, # A+R =o" 4 given binary number read from most fo) LR) = (LRP significant bit (MSB) (©) L(R,) L(R.) = 1a) (d) A Mcoremachine to find 2 IR. + Ry +A, + Ay) =2"— (2, 0. 1} a given binary number pression (0 + 1)" 1(0 + 1) signiicant bit (SB) ich of the following ia pao containing at least ea" bbe” @ Wore neo} ) eee om. np 20) Fronly (t) tgandr, only ©) L2anda i effyandt, (6) none of these @ 1.2,3and4 é @| 25. ‘Consider the following raguiar expressions: Z| 1. (ateoy 2@oy 2 3. (asby 4. (@ eb) 4 §. (asby 6. (b’a+a*by” é 7, (at aby 8 (bat ab)" e ‘Which of the following is trae? (@) only 1,2, 3 and 4are equivalent (©) all ie reguiar expressions excepté, Tand S are equivalent worwnmadeeasyin Pop STEMNNETASE {¢) allexcopt 8 are equivalent (d) allexcept 7 and 8 are equivatent 28. Match List| with Lict-landeslact the correct answerusing the codes given below the lists: Uist MADE EASY D 4 j 6 2 27. Match List with List-ll and gelect the correct | & answer using the cades grven below the lists: List 6 + THEORY OF COMPUTATION wnmwmadeeasy.in ‘Oconri esCEEASY foan NFA withoet «-moves. LEGS CASS «cam -nowa - shor - HYDERABAD Then yal, = @ ladeliz0) @) tabiclizt) fc) fab! | 120) (@) fabcy JAIPUR - LUCKNGW The language recognized by automata given below is (d) None of 22. WL,8l, UL, are ed {ollowingis true? (@) Ly has to be reguiar (b) L,noed notbe regular : (c) thas to be context tree i) sings ‘consisting of no consequetive O's (2) None of these ors 3. IL, ie regular & Lc Ly, then which of the |Z] 38 S338 following has to be regular? B30 @y Otay oe iy me Geos ‘The above grammar generates which language? WL =tabic | iz0} (al abe (©) aibx + be) L,=tabte! [iz 0} (c) alox}be: (@ (ox)"be THEORY OF COMPUTATION wwrmmadeeasyin eer 40. a. 46. Which of the following is true? Xe) String of O's, whose length is 2 prime {(@) regular sets are closed uncle infinite union ‘urnber {0} cubsots of regular sets are alviays regular (d) String af odd number ot zeros {6} subsets of regular sets are never reguter 47. Tho requ son is given by R= (ab- [d) subsets of finite sets are ahvays regular Pena ee pee | bb)" bbab ubich of the following expression does not belong to A? (@) abbbab fb) abab aby (©) abebbebbbab {d) abbabbbab Consider the grammar G=[S aA |h, A» 0B. B-+25} Which of the following strings donot belong to uch ‘a aaa a (©) aaagaa (@) onab The expression & + 14011)(1*(014)")" is equivalentto any i) (0+ 109)" ‘Which of the following langugy q@) G40niy (@) L=terb" | nz4) ee ing pairs of regular MADE EASY ea ela nized by the following finite (b) Aiven grammarisnet regu {c} Whether two given regular expressions are equivalenter net (@) None of the above Which ofthe Following aré regular? 8 {a) Sting of Os whose lengths aporiect square (b) Set of all palindromes made up of 0's and (@) (aa+e)(b+ ba) (baby is (b) “(ead + ba) (bab)* ‘THEORY OF COMPUTATION weremadeeasyin © CopmipeMRCEESSY Which of the following regular expressions ‘corresponding to the production grasnmar? (a) (apra (©) aa"D (o} ab" (0) aarba (©) (aa) (baby + (baby (0) (gab) (e+ (babyy 5g. The language recognized by the toloning stare hagrarn iss ‘The set (a + b)* does not correspond to which ‘grammar? 1. Sas |bSlalb 2. S+as | bs la 3. S+alb|ssla ioslalalb () any st number of b's (Any st number of b's of a's and odd numbers ot ‘The language accepted by the: Bes acriat ual number ofa's and b's 61. Whichol the following retationshipis tue? (a) Right Linear & Context Frea & Context Start Sensitive (0) Context Sensitive c Right Linear Context (@) a+ by (p) (2°) Fea “arbre @ fa+brarb) (c):Context Free © Right Linear & Gentext : Sensitive Consider the production grammar S — AB | (2) Contant Free < Context Sensitive c Right AS.A-ra | aA Bob linear ‘THEORY OF COMPUTATION wurmmadeeasyin 2 Cai MADEOSY (EIUSSSISEEN am tao (©) 107000 pba ©) a100 (9) 01071 . {@) None of these ror ‘THEORY OF COMPUTATION wnenmedeeasyiin © Coprche MADER (Construct ais equivatentio thenta given below and fing how many minimum states are in such 80, @s fo) 4 fey 5 @e 81. Which of the following sets arg 1 Ur or 10, 00, 000. 1 & {oynz tug equivalent cial, (Qp.5. 8, 05%. F) then 62% and Fc 2" Which of the following is false? {@) Every nia with <-moves can be converied to en equialentnta withoute-noves (b) Correspending ta every nfa there is an ‘equivalent rightinear grammar ‘THEORY GF COMPUTATION (6) Comesponding to every rightlinear grammer there is an equivatont lettinear grammar andviceversa (ch A grammaris regular tandonly itis either fightlinear or iefi-linear (6) Exery grammar can be converted Into an ‘equivalent one which is sight linear or left linear 85. Which of the following is false? (a) Every nfa with any number of finat state: hasan equivalent nfa with signatfinal state an nia with single final state wage L, then a machine M gall arrovsendmaking et belong to Ly? Be defined rom B10 1" as h(a) =9, hitb) = 4,140) = 10 “Leth, = 11010) Thenh"(L,) = {a} 0 (b) (ct, baba, cba) (0) |cc.cba, bac] (¢) [ee.baba, cba, bac ( eapyighe MADEEASE [OTST = van « nowa - BHOPAL - HYDERABAD - JAIPUR - LUCKNOW mar ‘Which of the following is telse? {c) at bv anda" 1" ther (@) h(n (L)) can be a subset of L {0} a bo and (0 17, 2M, n, M20 . rreayeantermoretct: | Lae, iin aorsinsncnttationra Fett (ner) =L 7 potneceseny tga = fa) LPL: Mor some fixed integer n Lotz = (0, andr = (a,b) a wie Leth(0) =aaand b(t) » bb ) LAL hes, Let L, = (eb + bay" {d) A subset or superset-of L, or L, y= (10401) (e) Noril,. L,)=tw | we Ly andw e Lab b= (ab 120) Then WML) ik) and tr" (ah (01 + 10)" and (bby neo) fe) (10+ 07) ang MADE EAS’ Let u=td Lf, 27 fay or 110 or LetL, =a" bat and l= bra then L, f@atbateat bj at (at bat (0) a* beat L,=arbandL, = b*. thenL il, = ? fa) abe (o) a (b+ =) ab we IHL, = at bt and L = {0 1"; m0} INIT (L)and INIT (LL) are respectively, (@) a b* and (0+ 1 (b) at + br and (0+ 1)" THEORY OF COMPUTATION ist-tt 1. Empty language 2. Finite language 3, Infinite language: Codes: ABC @ 12 3 mo 1 3 2 @ 234 @ 3s 21 99. The minimum dia that accepis the same language as accepted by dia gives @) ©) 2 101. Which of the flo (a) Hf p.q, rate 3 regular Liq), then p = pq + rip’ (b) (Oy OY" = 1H" (ACO) (o) (oy O= 1(00)" ((O+ Oe Ye 102, Match List with List-l and select the comect C., Both O's and 1's occur only is pairs D. No consequative O's E. No. consequetive 18 F Evennool d's List 1 + 11)" 2 Owny 3. (1400) 4. (e+ 10401)" 5. (1 LOIS (e +O} 6 (rorrorp et MADE EASY Parc equal nimod 3 =O} (od) L = [0" :nz0) 105. Which of the fallowing is requtar? (@) (017 ne mis odd) © conven Sy answer using the codes given below the ists: () 1 18:pq = €4] sts (© 19; p20.420, pq24} A. O’scccurontyin pairs {0) [08 12: p=5~a} B. Tseccuronlyin pairs @ Allare reguiar 14+ THEORYOF COMPUTATION ‘worncmadeeasy.in egy HADES (SISTER «can noon short « wvocraean - run - wwexnow PEWGESTS | 106. How many states are thare in a minimum state FAaccepling (0, 01,011,001) 4 5 6 7 onside: the grammar G,: S+Sab | AB Asanle BoB le t Gy: Soak AsanB |e Bore S—atb | Asc Which of iieen MADE EASY BY decimal equivalent of a 1 significantbitin reverse order. In machine D. actual oulputis taken to’be the last bit of the out put generated by the machine Codes: ABCD EFG @ 1234 6 67 ® 3215 466 ©1166 3 24 1156 243 re] mt 412. ISIE «car «no « srionat ~ineRABAD = 1APUR ~ LoeRvow [NEWGCS13 | The below machine-is, (a2 {o) S (4 5 445. A minimum fa for accepting the above language requires how many states? a2 ©) 3 ja @s Linked Question 116 and 117 (a) amealymachine tofind 2s complementof anumber (b) a Moore machine to find 2s. complementof anumber (©) amealymachine to ind 146. The nfa give below, accepts which language? witout writen parmasien, The belgg MADE EASY Unked Question 113, 113, 114, Which production resulting grammar will Gem starting and ending with 2, ae Which of the following is rue? AS OAL IBID (@) A grammar which is regular is either right B18 Jinear or let inca @) 8-18 (©) B08 (6) Unear grammars are either right linear er (S31 (dj B18 left linear [@) A regutar grammar is one which is ether rightlinear or left lingarorneither (6) S>a8|Bb{a is areguiar grammar A minimum dfa for accepting the language generated byresuting grammar requireshow many states? 16 + THEORY OF COMPUTATION ‘wawmadecasy.in 2 coprigh MABE DEY ——_———— SSS SS EEST cain moon mara wos nem - wonew PORES] 121. Thelanguagerecognized by he dlagven below (a) Losec Letand L(s).c Uy ove (b) Un cLispand L(g) < Lit) (6) Us}eLit}and Lis) clin) (2) Lit) Lis} and Lis) Lie) (e} None of theabove IGATE-1991] E, Which one of the following ig the strongest correct statomant about a fits language over some finite alphabet 2? (@) equat occurrence of sui recognizabie (b) equal occurrence gf ensitive language © Ings (@) Noneg MADE EASY ining machine fhe above statement [GATE-199] 123. Let A, and R, be regular sets defines E machine described in the figure alphabet £ then Should have a stable state, the restriction on bright (@) R.A, is notreguiar the inputs given by () UR, is regular Nout 2 esr of (ce) E-R, is regular (9) R, “ig notreguiar Sanaa einer . ERT 1680} (abet (as 124. Letr=1(1 +0)", 8= 11" Oandt = 1*Obe three (©) E+b=0 (@) ab regula jons. Which one oft pals cei expressions hich one a hestotng oe Sear IGATE-1993] 7 + THEORY OF COMPUTATION wennmadeeasy.in ‘© copyighe aDEEASY BHOPAL - HYDERABAD «JAIPUR + LUCKNOW 428. In.some programming languages, an identifier (@) Reguiar, Regular is permittedto be aletterfllawad by anumber (b) NotRegutar, Regular of lettersof digits. Land D denote the seis cf (©) Regular. Not Reguar lotters and digits respectively, which of the (q) NotRegular, Not Regular following expressions defines: an identifier? IGATE-1985} (@) (LUD) @uLvDy © (Lor if) LILO 134, Which two of the following three regular [GATE-195] expressions are equivalent? (¢ is the empty tin 190, A language with string manipulation facilities e a (e+0) uses the folowing operations 2 cor Head (5): fst character of a string ao Tail (s) : al but the first character of aaa @2eaa ‘Conitct (51,52) : 51 52 io horwot ene For the sting acbe what [GATE-1996] ‘Caneat (reacts), (@) xc 1b): Which of the (c) Prefixes oF L) fand has equal aumber Pet of all binary strings with une If the initial state is unknown, then the shor number of O's and 1's input sequence to-reach the final state Cis, (©) the setot all binary string including he nult () 01 19 hing ey 108 118 {@) the setof all binary strings with exactly ore [GATE-1995} | 5 Frese O's than the number of 1's or ‘1 than the number of 0's. Ad) Noneof teabove: Let = 0, 1), L=2* and R = [0° 1" such that > O} then the languages Lu A and A are respectvely THEORY OF COMPUTATION wou madeeasy.in Seep ec ADEA IGATE-1996} 138. Which one of the folioning regular expressions over [0, 1) denotes the sot of all svings not (oe (aa 995] ‘containing 100 as asubstring? IGATE-1998] (or(1+oy —(b) 0" 1010" i or ror () 010-41)" [@are-1997] 143. Which ofthe following statements is false? (2) Every finite subset of @ non-regular set is regular Which of the following set can be recognized (b) Every subset of a regular get ie regular bya Deterministic Finte-state Automation? (0) Every finite subset ofa regular setis requiar (2) The numbers 1, 2.4, 8, 2°, writen a) The nletsection of two regular setisreguiar binesy IGATE- 1868) (b) The numbers 1. 2, 4 earnest teary er expression (0+ 1)(O+ 1) (0) The set of bina im state finite automata of zeras is th ge represented by (@) The set MADE EASY ohher fiber [GATE-2001] Rover £ = |a, b) accepting all St The string 1101 does not belet ibebyé 4 represented by = ‘and number of b's divisible by 8. What is the a (a) 110" (0+ 1) ‘minimum number of states that the DFA veil (©) (041) 101 have? (©) (10) (1) (00+ 18)" @a fo) 4 © 004411)" OF 18 io) 8 [Gare 1998] [GATE-2001] Let L be the set of all binary strings whose last /@/ 148, The Finite state machine described by the two symbols are thesame. The number ofstates {ollowing state diagram wih A as starting state, in the minirum state deterministe finite state where an arc label is xly and x stands for 1-1 ‘automaton accepting Lis input andy stands tor 2-bit output, 13 + THEORY OF COMPUTATION wwarnadecasy.ia OC rah MADER [UEC cca nom = cron -rmmenanan «rR - wonow [eWecsis | won (2) the pigeonhole principie wo Er “Oe ED (©) the divide and conquer technique (©) recursion (c) Cutputsa "00" whenever ineinputsequence ‘contains “10° {© Noneofthe above sic ation of finite automata canmotbe found [uNU] gl (0) Reration oT 2 NU] (a) Outputs the gum of the present end the | & previous bits of theinput 28) 154, ¢ (Klcene’s closure of where 4.5 he empty (oy Outpace Ottwhenevertheinousequence |Z] 'erguegeoverE)is nuvaient contain “117 z @e 46) 0) 8 @E (q) None of the above : Thesmalest frite- autom: language Ix | length of x is g (@) 2 states (c) 4 For anon-deterministic fir 8, Op Fl. the transition func as B following regular excvessions ()8:SxE+8 @ (yer (O)8:SxE2 (bry (yan at eee (e) 8:8 xu foe O Gest et (d) Noneotihe above (@) None of the above [NU] 4160.. Which one ofthe following is a property of Moore Nu] 483. The logic of pumping lemma is.a. good example ot 20+ ‘THEORY OF COMPUTATION Twaninadceasy.in “2 be UACETAST See = E=E=SSSSS= —— $$ —— ———— (a) Oulput of Moore machine depends on present state and input {e) abebabaty {q@) abbbabbabababo stu) (©) Output Of Moare machine depends on a fuNUy state only Doty (c) Qutput of Moore machine depends: on | 2] 164. Letfbe ahomomarphisn, f(a) = 0, fb) = 1 and tpt ork {(o) = © (empty symbo)), Consider a language (€) None of the above Ls ("1 n>}, thentichone ofthe following [oNu} languages is t+ (L}? @) ev" | neo) b) foPa" | n> O} , * Which of the fotiowing pairs is not equivalent? 2) W019" and (1 0)" 4 ©) xboo}* and (cr (C) (ab)" anda’ b* (6) xt and xtc For the input, aabbbaaabbi : ful cannot end with 't' unioss the is put ends with "1100. (a) aaa {@) tonly (©) 2only (b) asoaaaaca (6) 2and3 (4, 2and3 LNU] © Consign 9900 Context Free Languages & Pushdown Automata Which of the following conversions is not (c) Regular language possible? (a) Regular grammar to Context fray (b) NDFAto DFA. (6) Non ceteris there Misa Maur (@) Non ceterminig Deterministic 3 (€) Reguier Langual {@) Nonecithe above’ The language L = [a°b0"b" {a) is context free {) is not context tree (c) abstract problem of checking aumber of fomnaland actual parameters {2} bath) and(e) Buinot CF Language 2 PPol torrninals that can be generated Fy he folowing CFG Soxy X-pax | bX | a yoya| yp la (@) Has atleast two a ‘The language L = {0°7"2" | n>Ojise {b} Should end in a’a (a) Conten irea ianguage (©) Has atleast one b (b) Context sensitive language * (c) Hasne consecutive a's or b's ‘THEORY OF COMPUTATION wwmadesasyin 3 Copy MADRE Givethe production Grammar forthelanguage | | 17. Considerthe grammar L= fab! | i>jzt) 5+PaQ [sal ps @)IS 2A, A+aA A+ a8, 8 + ab] Pox (HIS + 8S, S + aB, B > ab, A> aa, Qay Bb) To get a string of n terminals, the number of (©) 1S AB, 4-408 | a, B > oBb | ab} productions to be used ig (9) None of the ahove (a) oF ‘The produetion grammar in {S—> aStle, Sab) is (a) Type -0 Grammar (0) Type-1 Grammar (6) Type- 2 Grammar (0) Type-3 Grammy Consider tha (@) S—asb,.S Givwheray « Lisa (b) Sah, Sob, (©) S$ asbb, $+ abo (a) None of theatove ‘Thelanguage generated by Sra | aSb @) LIG) = {Ig | each prefix of g nas same |£) 21. Thecontext free granttar definingthe language numbers of a’s and b's} artis (0) L1G) = {g | each prefix of g has atleast as (@)S+sbla many a's as bis} (0) S+xY (6) UG) = [a | each prefix of g has unequal Xoax 1a, - number ofa’sand b's} Yopy|a {@) L{G) = Ig | each prefix of g has at least as (0.$+SS] baalane many a's as b's anct a's never follow. the SoA bs} (@) S+88|bex|sto|a, ‘THEORY OF COMPUTATION wwnm.madecasyin ecapyihe MDE EASY (aCe 22. 3...) ip anexample of a language hatis (@) context free (b) notcomtext free (C} not context free but whose complement leg (d) context free but whose complement is retCr ape 23. APOMbehaves likean FSM when the number ‘of autilary memory it has, is @o 4 je (@) Noneot A POM behaves ikea TM -auniltary memory it has, (a0 (©) 20¢more ACFGjg (c) taal ae (0, 1}} (9) {0x | xis palindrome} (©) fara | ae (0, 1) & xis a palindrome) 28, Which ofine following is true? (a) Allunambiguous grarnmars areregular fb) Every LL(K) and LR(K) grammar is unambiguous anda requiarlanguage can neverbe inherently ambiguous ore 24 + THEORY OF COMPUTATION (¢) An'inherentiy ambiguous language is a language for which there is at least one ambiguous grammar (0) A grammar is ambiguous if it contains a string for whichboth UMD and RMD can be vwniten (e) Reguier grammarsan always unzeibiguoUs Match List-| with List-1 and selectthe correct answer using the codes given below the lists: ‘To prove that L(M) =Lin itis sutficientta prove \@) thatevery sing generated by ris aceepted byM (©) that every string accepted by M is generated by r (c) bots and b (0) None of above (0 CopriteADEEAST Which is false? G,:8-9ASb | b,A> Ba, Boa (2) ACFG eangeneratea reguiarlanguage | Gy:S+ASb |b A>Aal a sa (b) A regular grammar can generatea CFL. (2).G, and G, only (0) Gyand G, only ibe (0) Ateguiar grammar can genorateany CFL (©) Gand G, ony () G,, Gand G, (d} A requiar grammer is alwe CFG ce (0) Areguter g veal Consider the following grammars; 92. CFU’sareciosed under G,:SraSb | 88] ¢ ect (a) intersection (6) Complementation (@) Setcifference (d) Regular cilerence G,:S-+asp | psa ss | ¢ G,'SsaSa | bSb |e 33. CFL’sare closedunder asa | spl elalb fa) min (0) max (G,Jand L(G, )cL1G,) (©) halt @ 3 (@) None-of these CFLS are notclosg 2) init © Mov) = n.6w)}and *} are examples of Bfid whose complemant is also (a) Land Lan DCFL's while LandL, and by (©) oot CFLs but whose complements aro CFL's are CFL's butnot DCFLUs: (c) are CFL's whose complements are also ae (©) L, and L, an DCFL's while Ly Ly and Ly an crs ted CFL's butnot CFLs (@) ae CFL's whose complements are notCFUs. {e) L, is OCFLandrest are CFLs butnot DCFL’s te is 43, Lett" ne0.ne 13}is is {@) AIS are DCFLs (a) aDOrL Which of these grammars generate the same. (b) a CFL but not CFL. fanguage? (@) rota CFL G,;S+aasb |b (d) arecursive set butnot CFL ‘THEORY OF COMPUTATION wwnmmadeeasz in SGopeniaswoeaar 44, [a bY; 2 0, 05 nota multiple of 3} {a) may or may not be a CFL {b) sa DCFL and hencea CPL (6) ia CFL butnota DCFL (d) isrecursive but not GFL 45. L=bey x=} poy. xy" Ly=boy, x7 29) (@) L,isa CFL, but L, and L, are not (©) Land Ly an GFL. but L isnot {c) Althree areCFLs {) Nonaof themis CFL 46, ACFGG isambiguaus. is fase? (2) al least one wg least 2 disting (0) at tog = (ww rwe fa, BI, 2c # fa, bl] a) L, ie CS, L, is DEFL, L, is not CFL, L, is regular {b) L, is CFL, Landi, an DCFLs, L, ie CS {e) Ljis@S, LandLy an’ DCFUS, L, is regular (@) Land L, are€S. L, and L, an DCFLs L, = fon, ce fa. b*} is (@) CFLoutnot DCR (b) DCFL andhence a CFL (e) not CFL a, b|*] is MADE = (©) There is procuctions in Which of following is tale Forsnarbitrary CFG, G, here: (a) tocheck if L(G) contains infrite st (b) tlocheck which variables appear in some | 2 sentential form {c) techeck which variables are nutable (@) tacheck whichvariables aeuseless: (e) None of these 43, two: w © fa, bit, x € fa, Bi (wow = we fa, BF, x ¢ fa, bil Eguiar language. Then 2 reguiar 4%) cannever be regular (©) isteguiar (0) has to be context tree 86. IL, ie CFLand is CFL, then L, nL hasta be (@ ace (©) content sensitive 26+ THEORYOFCOMPUTATION: Seprihe MADRS GSIEETSSIS oan toon wen - weaves “rm - anew [EWES] (6) recursive 62. Maich List-I wih Listl and select the canect (@) recursivalyenurerabie answer using the codes given below the lists: s : : List-1 3 57. ILyis CFL andl, is CFL, then Lng hasta A-S-aha|babla|b Re Asaal bale ec 8. $+28a| tsb lalble (canted seeetiee: starts and ans with same letter} Ehrecusve: CG. SaAa | bab (0) recursivelyenunerable Consider thefolowing CFG G,:SaSSlelb G,:SaSb$le|b both, ane Gare ut (a) The string MADE EASY {(d) both arenotrog ay ‘of properly balanced L=Uat by ures Lp= laren 20} Set of stingsanZ = {()} such b= tw | niwen, (wi) re number of felt and ight pareninasis Which of the following is true? @ Loh adsl andiial=b OL shad shandlab=b @ Ly chy andl,cLy and Len, = L, {yc Ly andl, cLy.and ty at, = by are-equal (0 None of these 65. Acontextree grammar is ambiguous if (2) the grammar contains useless nor-terrinals @ Conjrgnt Sobinck wal a (@) it produces more than one parse tree fer G,:$—+psslss |e . Some -sentance in abave Grammar, the String "b" has how many: {c) some production has twonon-terminals site parse tree by side on the right-hand side : (@o (o) 4 (8) None ofthe above os 2 (2) infinita [GATE-1987] + THEORYOF COMPUTATION worwmadeeasy.in etapa ALES i 66. FORTRANIsa (©) the left most and right most derivations of a) Fleguiar language the sentenco fb) Coniext-sensitive language ita then bthen ¢ : = 6 are not sama, (¢) Contexheetanguage (6) the sentenos 4Q) None of the above fa thon ifbihone: =delsec: =f [GATE-1987] has morothan bye parse trees (@) the sentence 67. Context-fres languages androgular languages are both ciosad uncer theoperation(s).ct a) Union (D) Intersection {6) Concatenaion (d) Complementation ifa then fbthene :=delee: =f thas two parse trees [GATE-1996} 68. Which of the following py undeciciable? (a) Membership org languages . (o) Wnether 2 gi while "is right MADE EASY {C) closed unc Dyremplysisck. Whictyot ‘The grammer whose prod ma xstimt> > if then csimt> > if cid> then (a) Ly=Le () gal @iyek (@) Nonect ihe above > : = ine albicidiell [GATE- 1998) + isambiguous because 75. tL, is context freelanguage endL, is @ regular {@) the sentence ita then fb then c; = dhas two parse trees + language whichotthe following is/are ‘alse? (@) L,—Lyisnet content free DL, AL iscontex free 28+ THEORYOFCOMPUTATION monnimadeeasy.in ‘© cepyreyn MADEEASY 6] DE EASY Fe “sHopaL -wooeineao - 1apun « womow [EWigeeas | (©) -L, is context free (6) =L;isreguar (©) The union of two context free languages is context tree IGATE- 1999] (6) The intersection of two context free languages is contextfree (4) The complement of a context free languages is contextfrao 76. ‘A grammar thatis both lefiand right recursive for a nar-tearinal, is (2) Aroiguae (6) Unambiguous (C) Information is not sufficient to decide [GATE-2001) 81. The language accepted by a Pushdown ‘whether itis an iguous.or unaribi utornaton in which the stack is limited to 10. (d) Neneottheabove 72, Let L denotes the lag MADE EASY 79. Gansider the follo 3,40" [nzt)is ae S10 189R+8 | me leniquage Which of the following statements is 6 “+ 08,8're} and (8! e} {@) Only 5,iscorrect [GATE.2003] {b) Only 8,88 correct {€) BothS, and §, are correct {0) None ots, and S, is correct 84. Select fromthe given options the grammar mile _aiter elimination of left recursion, aquivatent to [GATE-2001] ‘the following grammar rules with left recursion E+E sT 80. Which of the following statements is true? oT (@) If language is context tree it can ahvays ESE (ESTE beaccepted by a detenninistic push-dovn Ete EoaTe avioenston Ese ce 29+ THEORFOF COMPUTATION wimmadeeasyain © CepmigneMaCESE ESTE (E> TE Bowe ESTE 89. Is known thatthe language Lc fe. bj* thot consists of all strings that contain an equal [JNU] number of a's and b's is context-free. Let Mbe requlerlanguage ab". Whichofthe folowing The productions E-+E+E/E-E| Evel id cea ae fa) eae an inherently ambiguous 4). Kirhlipg Soutien 5° 2. Ley M isa regular language Eiooenicoe ee 3. LAM [at I n is apostive integer less (6) None ofthe above than integer) [uNu} fa) Nera. {b) Tonly (c) tand3 (d) 2and3 86. Which-of the following languages cang epee a lorministc fite auternata’ , snion-deterministic finite 2 [ato] kanzo} ai glioning is false? 3. Www lwe fa, be recognized dows anbe recognize: {e) Only [Nu] Prequal number of @ (GO € 1025 substrings} (OOOO) (dy as equal number of 0's [uNuy 9000 30+ THEORY OF COMPUTATION wawmadeeasyin coprireano SY that Ee ‘ Recursive, Recursively Enumerable Languages , &Turing Machines od Recutsively Enumerable Langua gbien product of countably infinite tat ai countably infinite sets is (©) Intersection (b) rocusive (c) NP-HARD (d) Noneof these es Baing is false? God canbe recesaniondiye 2 decidable for a alphabet Se ‘consisting ofa single symbol 1) Ds (6) Existanea'oi MPC solution => Exéstance of fe) NOM PC:solution {(@) nearly bounded:auicmats (€) Existance of FC solution => Existance of MPC solution (a) Both MPC and PC problems are undecidable 4. Let A& Bho countably inf sate. Which of the following is false? (@) Any subset of A or B is countably infinite (b) AUB and AXB are countably Infinite 5. Consider the folowing two languages () The union of countably infinite collection of Lag = (Wy. 9) | ww o Leta} countably infinite Sets 8 countably infinite Lo = [My 9) | we LEN) (@) Lyis not RE and L, is RE but not REC (©) Lis RE but not REC and L, is not RE (©) Both are not RE (@) Both are RE but not REC 10. if Land [ are a pair af complementary languages, which ofthe folowing fs not pssible (@) both Land T areREC {b) both Land LC arenot RE RE but not REC. and the Gorect orl other is not RE (@ oneot Lor T is REC. Any TH with m sym simulated using meng GSIECISISISSG « ceun - noioa - sxorat » MrDeRARAD + JFUR + waciow | EWEEST 15, The TMgiven below, accepts which language? R O"+® oak a) 10 n=O) (©) (O:n201 (b) (0°! n= 0) (2) loopson all words Linked Question 16 and 17 16. The TM given below, hangs (loops) on which strings, input alphabet is £= (017 MADE SASSY F every wel, ih E (@ recursive la (0) recursively enumer (c) NP-complete (6) context sensitive language = 14. IfLis RE butnot REC.then L must be (a) recursive (b) RE but nat REC (©) notrecurssively enumerable (@) NP-hard ing ie falee? Guar language can be accepted by an LBA (b) ADCFL can be acceptedby an NPDA oe ‘Arecursve language canbe accepted by aPDA (@) Any reoursive language can be accepted by some PDA 32+ THEORYOF COMPUTATION Cech ATETASY SE ich 24 26, Which one of the following is not decidable? (2) Given a Turing Machine M, 2 string s and GB __ sritoaerk, M accepts « within ksteos (b) Equivalence of two given Turing machines (¢) Languape accepted by a givenfings state machine is not empty (d) Language generated by a context froe grammars non empty Recursive languages aro ‘@) a proper superset of emntext ree languages o° always recognized by pushdown autemata ic) also called typa0 languages (@) recognizable by Turing machines IGATE-1990] 22. tis undecicebie whethor {al an arbitrary Turing machine halts afer 100 steps } aTuring machine prints a sp jollowing dacision problems (C)@ Turing machine oa ite state machine accept a oftwonumbers (4) None of the ay IGATE-1997) eres cd ‘Which of the following st {a) The Halting problemol Turing 18 computation of M on w visit the undecidable stale q? (b) Determining whatharacantext-free grammar Whieh of the follewing statements about X is 8 isambiguous is undecidable correct? {c) Given two arbitrary context-free grammars ) Xis decidable G, and G, it is undecidable whether (5) is undecidable but partially decidabte UG) = LG.) (c) X is undecidable and not even partially Seepage {@) Given tweo regular grammars G, and. itis decidable undecidable whetherL(G,) = L(G.) (d) Xis nota decision problem (GATE-1996] (GATE-2001] THEORY OF COMPUTATION wwewnadeeasy.in OCopynghtMADEEASY. 30, Which of the fosowing is tro”? {6} Non-deterministic Turing Machine M {2} The complemert of recursive language is semidecides a language it and aniy i for recursive allweL, Maccepis w (The complement of a recursively {0 he case of recursive Mouemgas® sc enumerable language is recursively gub Ea OF the Claes.) ERaaeNe eusrecabls eumerabie languages (6) The complementota recursive language is either recursive orrecursively enumerable | =| 33, (G) The complemertofa context ree language is context tree NU] Thenext neve function § ofa Turing Machine M (0.5.7.8. 95, 8. Fis a mapping @) 6: Ox O xr IGATE-2002} ) 8 Qa Qe och, FY 51. TheClanguage is 5 aera {a} Acontext ree language SQ xT ath, oo fb) Accontext sensitive la (nu) lc) Areguiarlangua g statements is i290? a) Parsale fully g patis accepted by a a recursively 34 + THEORY OF COMPUTATION wermmadeeasy.in © Copmigte MACETASY for ct ly ; Computational Complexity- ‘ P,NP, NP-hard, NP-complete 1. The number of syinbots necessa ba RE and L, be dacidatieandL, be 1 a Tuning Machine" withm g lolowingis false? is ee man fo} mn 2 AT (@) If any NP-complel® NP=P {0} All of above 4. Given L,, L, are NP-hard and L, is in NP. (Note: ‘As, B means A is polynomial reducible to @). | | % Whiehol hekalewing protiems is rotNP hart? Which of the follaviing is false? > ecg 20/1 knapsack ps Lyis NP-complete iL, ¢ NP and L$, L, ptameragg? ) Fincingbicornected components. ota arapin (©) L, is NP-compiete iL, =, Ly 4d) The graph coloring problem : (@) L, and L, may be polynomial reducible to [GATE-1992] eachother 9900, 35 + THEORY OF COMPUTATION Wimnmadeeasy.in (ecoppaghenaOeEnSY MADE EASY Introduction Input List A compilation B. interpretation CC. macro definition 3. D. keading Codes: % _insome phase of eompiter A Bc D @2oa441 ms 2 4 4 4 2 1 3 O32 14 2 Match List-l with List-Il and select the correct answer using the codes given below the lists: COMPILER DESIGN cessor 1. resolving external reference 2. loading the program producing relocatable MADE EASY Bing acompiler fonal ta the complexity of the eplanguage ) is proportional ta the comploxity of the architecture of the target machine (©) Is propartianal to ine tlexibility of the avaliable instruction set {@) allofine above 6. Backend at campiler includes those phases that depends on (je) tzget machine (o) source language {e}_ both a) and ib) (6) none ofthe above wormmadecasy.in ‘Scop RADEEASY Frontend of compiter doesrotinclude tne phase (@) sorrante analysis 9 {b) intermediate code generation (©) codeoptimization (0) nonadl the above ll A programming language which allows recursion can be implemented with static ‘storage allocation |. No L-aitributed definition ean be evaluated in the framework of bottom-up parsing Code improving transformations can be 8B. ‘Which of the fotlowing phase of compilation performed at both source language and process is aneptional phase? intermediate code level (a) lexical analysis fa) Land tt {) Land iv (b) syntax analysis {© iiland lv (@) All and Iv (c) code optimization [GATE 2009} (Shreose geetion, der the rule of the C programming “every variable must be declared ‘cho! thefellowing phases A compiler running of compuy memory would normally bg (a) amuli-pass comp, {o) single pass cong using she opposed tousing st (a) Somolorsizes of & is the name of data (©) Lesseroverall page fe Jer that is responsibie (©) Fasterprogram startup imation about variables and th (@) Existing programs neednot be re-linkech® eles? take advantage of newer versions of (2) Abstract syntax tree Toraes (b) Attribute grammar (©) Symbol table 2 SSE a (@) Semantic stack Oo 12. Which ofthe ietiowing statomerite are TRUE? [JNUEE-2009] |. Thare exist parsing algorittens for some rogramming languages ‘whose z 0090: complexities are less than g(a?) [DRDO-2009] 38+ COMPILER DESIGN wommamodeeasyin Compr maDesaST Lexical Analysis The number of tokens in the fa Gonsicler the following ents isfare true? 1. simpity ine phases 2. compiler efficiency is impro 3. compiler works faster 4. compiler portability ie enhanced (d) both S, and S, are false Which is/are truz in context of lexical analysie? ‘A grammar is defined by @) 12and3 (by 1, 3and4 SWE We RIV X a KY yyy, Zo (©) 4.2and4 — (@) allofine above Zizz . Which of the following regular éxpressians . Which of the totowing transition diagram carespancls hie paras correctly define identifier and keywords? Weigle preci (3) eC yy" Ize") (@) boc | yyyraz™ wwmmadeeasyin ecapighe ALOEEASE Metisse DELHI - NCIDA + BHOPAL - HYDERABAD - JAIPUR - LUCKNOW 8 If(z== a)tunction (10); 14, Given below are theregular expressions The nuriber of tokens in the above statement 1 (iby 2 ey are 3. fay" )9 (ot Cprnicn of themare equivalent? ) 0 (a 2 (@) tonly (b) 1 end 2 only net Let L denote the language generated by the () 2and3only — (d) allafthe above grammar S$ +007; T+ 118] 11. "Sis the start ‘symbol then which of the following is true’? (@ L=o10 (0) Lis regular out not (0 1) {c) Lis context free but rotregular. . (dG) Lis notcontext free gcepts the same language, i.e. 15. Given woDFasa, and M, They are equi it (a) M, and M,has the same number of sistes (b) M, and M, has the same number of fing! ent Which of the fo MADE: EAaSy¥ (@) noneotine abd Ita NFA wit has n stale nurbar of states the equiva are @r yn ge {d) none of the above 40 + ‘COMPILER DESIGN worvemeadeeasy. i Te ceeynche SEE Parsing Which of the following sulfice arbitrary CFG toan LL(1) gag (b) Factoring ne g (©) Removing lefg The grammar is. fa) LL) 4b) SLR (1)but not LL (1) (©) LALR (1) but not SLR (1) (@) LRA) butt LALA (1) [GATE 2003] ‘The grammar AAA (A)! es not sutable for presictive-parsing because the grarnmaris (@) ambiguus) Left-recureive (6) ‘fightreGurisve (@) anoperator-grammar IGATE 2005] g following grammar. } Which one of the following is talse? (2) The code contains loop-in variant ‘computation (b) There is scope of common sub-expression eliminatianin this code (©) There is seope strangth reduction in this code - {d) Thereis scope of dead code elimination in this code [GATE 2006) COMPILER DESIGN caaright BELLS Which ore ofthe followings. top-Gown parser? (@) Recursive descent parser (0) Operator precedence parser () ANLAM)parser (0) AMLALAG) parser [GATE 2007} Considerthe grammerG:S— Aca aco Ase Boe where S,A.and 8 are nonteminals anda, b, ¢ are terminal symbols. The (@) LL) butnotLL1) {b) LL(2) butnot LAO) (c) SLA butnetLL(1) (@) neither LL(2) nor! a. If a grammy ia (©) an LAO) parser can the LU) parserhas S-Aca (@) an LACH) parser can have S-R et the SLAC!) parserS-Reonicts [DADO-2009) Find the best match between the elements of upland Group-II givenbelow Group Group-il P. Dataflow analysis 1. Lexical analysis Q. Regularexpression 2 Semantic analysis 11 ‘COMPILER DESIGN warwemadeecsy.in RL Tyne Checking 3. Parsing S. Pushdown Automata 4 Code Optimization P4,Q4,83,S-2(b) P-2. 0-1. R453 (©) PH.O4R2S3d) P4.04,R-2,53 IDRDO-2008] Which of the following isfare tae? L. Aleft-recursive grammar cannot be LL{1) NA right-ecursive grammar cannot be LA( 1) IM. Every grammar that can be parsed by a anorical LR parser can also be parsed by and tt [PRDO-2008] er containing (@) lexical error ing which is the right side of a production such that replacement of thet substring by the symbol left side leads to a reduction to the start symbol by the reverse ot -arightmast derivation is called a . @) hands te a © | (©) recursive descent parsing (@ leftsocursion econ MADER 16. A.shift reduce parser carries out the actions Spécilied with in braces immedistely after reducing the corresponding rule of grammar, A> bbB (print "s"] Ama prin) B+ Ac iprint “7 What is the translation of bbbbacc using the syntax dieeted translation scheme described by the above rules? @) t+-4" )tt-at (by ** (4-4 ‘Which of the follawing st We ‘Check hich of the follwing is correetier abowe ‘grammar? (@) theabove grammar isin recicue form ) the above grammar is not in reduce form } from given nar-lerminal we get the none terminal only thus above grammer is in reduce form (2) none of the above Conve the above grammar to the necuced form 96 grammar is not in reduced forn Pat (0) AICFG's are LR and uniquely defined. (6) Every SLR grammaris unambiguous every unambiguous grammaris SLA. @ LAUQ is the most general back tracking shift reduce jrarsing method. Linked Q. 20 and Q. 21, 20. SAB . S2C8, Bosc - Boas Ata CB lb B Gopyrion Subract ma Pbiree sets areciferont IGATE-1992] 23. Considerthe SLAC TandLALR(1) parsing tables, jor aconten free grammar Which of the folowing statements is/are false? (@) thegatopartat bantables may bediflrent (©) the shift entries are identical in bom ine tables i (6) thereduce enties ithe iablesimay be citerent (0) the enor enties i te tables may bedierent IGATE-1992] COMPILER DESIGN ‘wmemadeeosy.in conyrine MEDEERS 24, Inthe folowing grammer Y Ximxok vy yok z (witch arine fotowingis rue? (2) ‘Wisletasscciahe who isrightassociatve {@) both Sand" are leh associative (6) ‘@tsight ascociabvownie “isiakzeeocitve (@) nenecttne above IGATE-1997] Given the following expression gig ESE'FIF+E|F Which of the fotla E— number [EWE IEXE Theabove grammar andthe semantic nua re fed to.a yacc tool (which is an LALA (1) parser genera’) for parsing and evaluating arithmetic expressions. Which onedf the followingis true about the action of yao forthe given grammar? (@) Ihdetects coursion anc edminates recursion (b) it detects reduce-educe conifict, and resolves ? PEC tan «woos «mom -oamno “nn -ncnew [EWE (C). itdetacts shit-reduce contlict, and mechves tho confictin favor a a shift over a reduce action (0) itdetects shift-reduce confit, and esohves the conflict in favor of a reduce over a shift action 28. Assume the conilicts in Q.17 are resolved and an LALR (1} parser is generated for parsing arithmetic expressions as per the ‘grammar. Consider an exprssion 3x2 + 1 iatvity properties dows rated parser reniza? ADE EASY a production that may be used for eduction in a future step along with a Postion inthe santantialform where tyenaxt orreduce operation will cocu: (J) it is the production p that will be used for eduction in the next step along with a postioninihe sententialfarm where the right and side of the pradustion rnay be found [GaTE-2008] “4+ COMPILER DESIGN © Cope HOLEASY 31. AN LALR(1) parser fora grammar G can have shift-reduce (S-f) conflicts it and only if (=) theSLA(T) parser fur G hes SRcontlicts (2) the LAL1) parser for G has $-R cantcts [kc tre tno) parser ior G has $Reonmots (d) the LALR(1) parserforG has reduoe-reciuce contiets IGATE-2008} 82. Considerthe following parse tree, Where Sis the start symbol, X is a nonterminal and 0, t, a and b-are terminals. Which of the following is true about he grammar G,? (a) G isleftfactored () G, isteft recursive: 9 (©) G, isunambigous {d) noneat the above A grammar whose parsing table hase muttioly MADE EASY Consider the following Sox XK fe > a¥[b a ofthe following is not LA(1) tem set? @) S+x,3) ©) [saa] b]$) &) Mob. a]b/ 5} (A) fra Ya] b/Si[¥+-2¥, afb/s} 85° Consider the follawing production ne for a S convient Suvieet mal * grammer, SxO|t Xo Xa [Sb] Giving productions for a TS/HEtSes and cortiguration of he parser is as follows Steck Input -IEtS Bw The above production sroduces which of the following action? @ shine ©) reducethecenfiguaion — EJ (0) shiltkeduce contict () reduoejredtuce contlict 35 + COMPILER DESIGN aT 39. Consider the following augmented grammar “The above grammar is EOEESE+TIT ToT xf, F-»()|id and {@) notkL(), not LL(1), not LAO). But SLA(1), iflisihe set of two items {{E > E+], (E+E: + LAUT and LALA) ‘Tihther ip the caseof SLR pareor stuch of he (©) PotLL(0), not LL(T), ot LA(O), burSLA(1), (B trtowing items is netin goto (1, +) function? Ltn and not LALAQ1) MeSee TW Teer tak ©) rett1(0), not LL), not LR(O}, rot SLE) () Fovid (Fo ia: bul LACT) ang LALR(1) 40. Consider the fotlowi (6) rotLL{0). notLE(1), not LA(O}, net SLA} 55-9 9K rot LAC?) and not LALPK1) xox} . EQ) Presrotical Le retoa tx 0° 0118 an A Si ec parr cares tt he actors pontesshun ihe eboigwinie ecified with in braces immadiataly after of the tem? ip the comesponding nule of grammar (a) 000 @ on (ramimar production. (a) LAC) < GF FA are respectively Thegrammar STA A+a1+TA Toijn O asu (©) SLALA(1) (©) LAU) butnotLALRtt){s) —isSLR(t) Pa (oy (Consiger the following grammar with terrninal = alphabet E = (.}, +. “| and the start symbol 44. Consider the following grammar G. z Toran ote g See 1 Sax sto “2 oat Ean) 3. X32 Atel Ele & hae FIRST (A) and FOLLOW (A) are respectively 5. BoA 46 + COMPILER DESIGN winmadeeasy in een a ESTES bas. noon onorm toh (Se, +, “}and [s,)} fe," and is) Cte) (ss anais.1 (} f+, 4() and ($9) Consider the following grammar, S—Aa|bAG | de! bda Asd The above grammar ig ) @) rottaur(yousta(t) (©) bothLALA(1) and SLA(1) (c) LALR(1) butnctSLAKt {q) neither LALR(1) ng ‘Whatwillbe the of leflrecursigg Eo, (2) bomns, ands, ‘The grammar $ + aa [D5 (2) LLM) but not LAG) (0) LAG) but not LLG) (c) BothLt (1) and Lat) (@) Nether LUT} nor LACH) [GATE-2010) 4 Syntex Directed Translation 1. Cansicer the syntax directed definition shown (0) transiation of construct in tars of memory balan. essociated with ts syntacti eamponent S+id:=E fgen(id.places n of consinuct intemns of execution E+E, +E, ite giod with its syntactic esi parse tree ‘Compute E. value forthe root ot the ga for the expression: 2#3&595.& 4. (2) 200 (b) 180 160 0 ‘Whichottne fetlowingatribute canbe: by shill reduce parser that executes tion only at reduce moves never ats! (SRE syihesized atrbuie 3. Asymax directed definition specifies | (b) inberted attribute {@) translation of construct intermsof attributes (@) both (a)and (b) ‘associated with ts syntactic eamponent (9) nonect the above COMPILER DESIGN ES RECTEESTES] onus «novo = piorns - mvpewean -saun - wemnow 6. TheBAG shownhere represents /\ 10. Consider the DAG with V = (1, 2,3, 4,5, 8}. shawn belew, O#BKG89848542 will be IF*Fvel* gives the value off generated by Fin the above gramme willbe the value of Fval on input 101? @ 25 fb) 550 @ 10 (a) 485 A &) 12740 (©) 400 (d) noneot the above 13. A synthesized attribute is an attribute whese value at a parsetree node depends on (a) atiibutes atthe siblings only (b) attributes atparent node only (ec) attributes atchitdren nodes onty oO (@) nome of the above 9. Adrected acyctie graph represents one form intermediate representation. The number of ‘on terminals nades in DAG ofa=(b-c) (bso) expressionis : Scoping Seana a Oa ¢ ; 14, An inherited amibute is the one whose intial \ ‘value at parse itee nadetis defined in terms of 29. COMPILER DESIGN wirmmmadeeasyin cepa sr Sd evn - noiwa - shorn (@) attributes at the parent andjor siblings of that node 6) altributes at children nodes only (C). attributes atboth children nodes and parent andi/or siblings of that nade: id) none of theabeve Agarbage is (@) unallocated storage: a allacated storage with all access paths toit destroyed (€) allocated storage (d) uninitialized storage 16, Apietorig! representation g by each statement in Consider the trenstaio S4TR R47 (prin ( +} Rie > num {print inumval):} Here numis a token that represents an integer and num.val represents Ine corresnonging integer value. Fer én input sting 9 +5 +2, this translation scheme will print (O+S+2 95424 () 9524+ (+4952 IGATE 2003} | ocean non - wee RETEST 20. Considerthe grammar S-+L = AiR LoApa 9 Rot ‘Which of the following set af LA(O) items defritely coes notrepresent avaiid state ofan LA (0) parser? (2) SOL=A,R> Rib} Lovid® () Sola A R-+L (a Rab IORDO-2008] Thefofowing syriardirectedtensiation scheme sed with a shift reduce (bottom up) parser gs actionsin braces immadisialy ster be corresponding productions: ‘COMPILER DESIGN wwrw-madeeasyin Type Checking Which ofthe faiowing chooks are ing siaie checking? (@) tyne checks (0) flow checks (@) uniqueness of @ aia from one type to another type fs by the compiler then, itis MADE EAS CO) by he program? @) texicaleror (©) semantic enor (d) 109 ‘Consider the following C fragmen ‘to int x = 0; x =n; x44) hich type of error detected by the C compiler lorthe above code? (@) lexicalenor —() syntactic error (0) semantic error (d) logical error Bry sources of semantic error are 6) undeclarednames "{8) ‘ype incompatit (©) both (a) and(b) (@) noveattectove EF Runtime Environment ‘Consider the grammar rule E> E, ~ E, for arithmetic expressions, The code generat targeted to. a CPU havinga single: ) deep access The subtraction operation, operand to bein the have any commmeon, ‘get the shortest pg (a) E, should Approach used 10 implement dynamic scope (0) mone of the abo Flages which permit a 3. After the assignment pI address 200 is associated wi used, then the assignment change allocation schema for a (@) environment — {b) state ecards, (e) binding () none ofthe above (2) Band 5 only (©) 1,3and4 only 4. In gach activation of a procedure, the local + variable name in that procedure is bound to 1 Leeson 4d) 2,3end Sonty . storage location, wa OS iteen sore ines tere (SATE: 2008 (6) same (2) none of the above 52+ COMPILER DESIGN ‘wurncnadeeasyin eCieart MALES + DELHI + NOIDA + BHOPRL «HYDERABAD « LAPUR wonow [EWGEsTS | ‘The following program fragment is wrilien ina Common Data for. 7 and & O:s0-16, Ro=ReP programming language that allows variables End: and does not allow nested declarations of begin train functions A= 25,8 = 9.0; global inti= 100, j = 5; DOITB-A, A, Ay; ‘void PG) | OD rrirtiay inti = 10; Ends, maint print (x4 10} i= 200. fa) 25 (b) 85 (d) 108 print ix): yving statements, has better performance function fly. x, 1 rea xed: ‘enigma (a, b): yexeyer wiite (a: write (b); | end mys (oh 24,7 tb) 7,24 (c) 31,3 (2) 20,7 ‘The output of procedure mys depends on the parameter passing method. What is the ouput of the program segment |] 11. Suppose that all parameters are pasced by ~ below tthe compiler Operaies cal by reference? | Procedure DOIT(P. Q, R};- value. Which of the following values. ar@ the iputwhen procedure mys called? begin [ a=2be=7 (b)a=2b=9 ()a=9b=14 (d)a=14b=16 53+ COMPILER DESIGN wwmemedeeasyin ‘Occpymgen:RSELAGT (SRETTSEIES «can soo sno -noenae AA - ERO 42. Suppose that all parameters are passed by reference. Whichat hetolowing areouputuben procedure mys ia called? fe) a=2b=7 (b)a=%b= 14 Eo ar tab- 16 a-20,.0=20 15. Theouput produced by caling in a language with static scope will be y 1 ()2 3 @a ‘Thecutput preducediby calling Pin a language with dynamic scope will be ft (wo) 2 ts id Common Data for Q. 17 and 18. Consider the following programina Pascabike 16. Common Data for Q. 13 and 14. Consider following program int bs main() MADE EASY ‘Common Data? ‘Consider the folowing pro Brogamuwhen all of te procedurep; rom Bed by name? x integer: (0) 373 procedureg; begin x:=x+ Tend: oa © procedwer, Common Data for @. 19 and 20. x: integer Consider the pseude language like C. begin x= 1: g: write(x) end: ney; begin Pry r end, function Pinta) (n+ 2-3); (EAGT cia - noon - snort = woman sama Ta ~ woo WEE function OO 23, Considerthefollowing statements, S1: Staicscope determines the declaration that applies to a name by examining the program text ‘$2: Dynamicscope determines the declaration tat applies to a name by considering the current activations. Which ofthe above statemants isfaro tne? (2) S, Istueand S, is talse MADE EASY OO 82) D ateageat Which of the above (@) Stis tue 82 ista (©) S2is tue S1 is false (c) both St. anas2 aretrue (d) both $1 and S2 are alse 22, In state scoping undefined variable (3) searchin upper block (6) search where the function is called (c) ‘relers global variable (9) none of the above 55 + COMPILER DESIGN wnnwmadecasyin ‘OconyNLMACEEREY 7 Intermediate Code Generation 1. The intermediate coda generated for the following syrtax tee is MADE EASY (@) it refers to the index of the first statement of second expression (©) it refers to index fo the fist staternent of firstexpression ‘ (©) it refers to merging of list of statement af two expressions: (9) refers to the creation ot index of se statement pynnbeaD 5. Generation of intermediate code basedon an Which of the following is not a type of three abstract machine model s useful in compilers address statements? becauee {) copystataments {a} it makes implementation of lexical analysis: {b) indexassignment statements: and syntax analysis easier {c)_pointerassignments (0) syntax-directed translations can be written {¢) nonectthe above: forintermediate code generation [© tenhances:ne poraitty of tne ron ena ‘atthe compiler (d) itis not possible to generate ogg machines directy from hig ‘Consider the following statements. St: Three address cade is a linearized presaniation of a syntax tree gitax tree not depicts the natural re of source program g statements igfare tua? ADEE EASY a A+B” CAE TA)". Transform ‘Q' into its equivalent expression (a) ABC“ DETFIG*-H + (0) ABG "DEF TG"H—* + (9 ABG "DEF T/G*-H™ + (d) none of the above 57 + COMPILER DESIGN wwrmmadeeasy.in © Gri MADCEASY Code Optimization 1. Substiution ofvatues fornamesiwhese values | | 5: Consider the grammar rule E > E, — E, for are constants) is done in arithmetic expressions. The cade generated is (2) Localoptimization CPU having asingle user register, (©) Loop opimization operation requires the first (6) Gonstantfotding citer WE, arid E, do nat (C) Svengthreducti ssion, in arder to fontains loop-in. variant jereis scape of common sub-sxpression elimination in thiscode (©) There ts scope strength reduction in this code {d) Thereis scope of dead code elimination in this code machine independent optinizabe in aseparate optimization phase Machine clependent optimization has feduced both the memery space nesded ‘for the program and the execution time of ‘the object program: {a} only (b) only 2 (©) both and 2 (¢) neither t nor? [GATE-2006) 58 + COMPILER DESIGN wre madecasy.in Cepia IMEC HYDERABAD = JAIPUR» LUCKNOW 7. Somecede optimizations arecariedouton the | | 11. Constantiolding means intermediate code because (2) replacing expressions bytneirvalues, tthe {@) they enhance the pertabiliy ofthe compiler valvocan be computed at compile time toothertarget processors {(b) replacing an operandby constant (©) program analysis is more accurate on (6). ignoring the constant intermediate cade than on machine code (d) noneorine above (©) the information trom: data flow analysis Cannot othenvise be used for optimization (2) the information from the front end cannot otherwise ba used for optimization Poplin 12, Whichotihe follewing is nota loop eptimization? (@) induction variable elimination Consider the following $1; Constantto of more general (9) none of ne a Consider the follow optimization. i= 1j=0; whilaj

You might also like