The Gateway to Computer Science Excellence
+30 votes

Which of the following statements are TRUE?

  1. There exist parsing algorithms for some programming languages whose complexities are less than $\Theta(n^3)$

  2. A programming language which allows recursion can be implemented with static storage allocation.

  3. No L-attributed definition can be evaluated in the framework of bottom-up parsing.

  4. Code improving transformations can be performed at both source language and intermediate code level.

  1. I and II
  2. I and IV
  3. III and IV
  4. I, III and IV
in Compiler Design by Veteran (52.2k points)
edited by | 5k views

For point 2 we can refer to  question  (point 3)

2 Answers

+33 votes
Best answer

Answer is B.

  1. Yes there does exist parsing algos less than $\Theta(n^3)$.
  2. It cannot be implemented with static storage allocation. It needs dynamic memory allocation.
  3. If the L-attributed definitions contain synthesized attributes then it can be evaluated.
  4. True.
by Boss (19.9k points)
edited by
can u pls elaborate option C ?
every s-attributed SDT is L-attributed SDT (vice-versa need not be true)

S-attributed SDT follows bottom up approach. Hence L-attributed SDT which are also S-attributed can be solved by bottom up parsing

which parsing algorithm takes less than O(n^3) plz explain .........i know CNF but in take O(n^3)

plz elaborate??
CFG is O(n^3)
LL and LR parsers are linear time parsers.
how can be done code improvement in source code?
As a programmer, you can always try to improve time complexity
Also a programmer can use addition instead of multiplication
You can even use code optimization techniques that happen in intermediate code level in your program
(like loop unrolling etc)
In recursion, we know that the recursion stack can grow to any extent. Is that the reason for recursion requiring dynamic memory allocation ?
L- attributed definition can contain synthesized attribute. So I think it should be D.

If L-attrib definition contains only synthesized attributes then it can be evaluated using bottom-up parser.


Some L-attributed grammars (including those with non-synthesized attributes)  can be evaluated by a bottom-up parser. 

yeah, i just missed that, anyway option C is false.

Predictive Parser runs in linear time.


A programming language which allows recursion can be implemented with static storage allocation.FALSE

 It needs Stack storage allocation instead of dynamic storage allocation.

recursion requires stack and not heap(used for dynamic memory allocation)
Can you please, state an example.
+1 vote

LL(1) and LR parsers are linear time parsers. ie, $O(n)$

I is True.

PS: Recursive descent parser runs in $O(2^n)$ time.

Recursion needs stack

II is False

L-attributed definitions have both inherited and synthesized attributes. Can be evaluated with top-down-left-to-right style.

S-attributed definitions have only synthesized attributes. Can be evaluated with bottom-up style.


So, in case a definition only has synthesized attributes, we can call it both L and S attributed. Such an L-attributed definition can be evaluated with bottom-up style.

So, III is False.

Code improvement can obviously be done at the user-level by not writing stupid code. And compiler also improves (optimises) the code. Hence,

IV is True.
by Loyal (6.4k points)
Every S attributed grammer is L attributed too and S-attributed SDTs are evaluated in bottom-up parsing, as the values of the parent nodes depend upon the values of the child nodes. This means some L attributd SDT are also solved in bottom up fashion , which prooves 3rd statement is FALSE
Correct! :)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,302 answers
105,007 users