in Compiler Design edited by
6,729 views
23 votes
23 votes

Indicate all the true statements from the following:

  1. Recursive descent parsing cannot be used for grammar with left recursion.
  2. The intermediate form for representing expressions which is best suited for code optimization is the postfix form.
  3. A programming language not supporting either recursion or pointer type does not need the support of dynamic memory allocation.
  4. Although C does not support call-by-name parameter passing, the effect can be correctly simulated in C
  5. No feature of Pascal typing violates strong typing in Pascal.
in Compiler Design edited by
6.7k views

4 Comments

Anybody, please answer the question.
0
0
edited by

@Lakshman Patel RJIT Sir, difficult tag should be made as normal

2
2
Does dynamic data type refers to structure ,union??
0
0

6 Answers

28 votes
28 votes
Best answer
  1. is TRUE. Left recursive grammars if used directly in recursive descent parsing causes an infinite loop. So, left recursion must be removed before giving to a recursive descent parser.
     
  2. is a strong statement- but I do not have any proof or reference for this- so for now I consider this FALSE.
     
  3. is false. The language can have dynamic data types which requires dynamically growing memory when data type size increases.
     
  4. is true and using macro we can do this.
     
  5. out of syllabus now.
edited by
by

4 Comments

That says

1 If language doesn't have rec or pointers still we need dynamic memory for some other datatypes

2 For using dynamic allocation , language need not necessarily support pointers ..
0
0
edited by

A programming language not supporting either recursion or pointer type does not need the support of dynamic memory allocation

Lets make use of logic here

p :  A programming language not supporting either recursion or pointer type 

q:  does not need the support of dynamic memory allocation

Your statement 1 violates p -> q (which is the case here and hence it is False.)

Your second statement says q ->p

Is p ->q == q ->p ? No

Your second inference is not correct.

Analogy :

If john is sick, he will be at home.

That doesn't mean if he is at home then John is sick

 

0
0
  1. is false because 3 address code is the best suited code optimization 
0
0
10 votes
10 votes

a) False

Explanation:The support of dynamic memory allocation is needed, when during compilation, the programmer does not know about the maximum requirement of memory by the program. It gives the flexibility to assign memory as per requirement during run time. Even when maximum or worst case memory allocation is known beforehand, usage of dynamic memory allocation leads to efficient programs in terms of memory usage.

b) True

Explanation:In the call by name parameter passing technique, unevaluated expressions are passed to the function and the expressions are evaluated in this called function. The functional programming languages like C which does not directly support call by name, can use thunk to implement the same. Thunk is a subroutine to assist call to another subroutine. During implementation of call by  name strategy, thunk can be used to evaluate the passed expression and that evaluated value can be used by the original called function. Check out more about thunk and examples @ http://en.wikipedia.org/wiki/Thunk

4 Comments

@SiddharthBhardawaj

what i think is Int array[ ] command internally contains pointer, please correct me if i am wrong.

0
0
edited by
I think that a also has to be true, because without pointer how you can use that memory which has been allocated
0
0
In java,there are no pointers still it uses dynamic memory allocation .So. (a) is false.
0
0
4 votes
4 votes
A for sure, not sure about E

4 Comments

ok :)
0
0
what about option b & c ?? They both are also true right ??
0
0
I know about call by name , but can you explain statement d ? please.
0
0
1 vote
1 vote

a) False

Dynamic Data type was introduced in C#.  Dynamic data types are dynamic in nature and don’t require initialization at the time of declaration. Expression for dynamic data types is evaluated at run time, So we need dynamic memory allocation

b) True

This technique is used in programming language such as  Algol. In this technique, symbolic “name” of a variable is passed, which allows it both to be accessed and update.  For Implement it in C it can be done via Thunk:

https://en.wikipedia.org/wiki/Thunk

Answer:

Related questions