edited by
6,771 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.
edited by

6 Answers

Best answer
28 votes
28 votes
  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
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 votes
4 votes
A for sure, not sure about E
1 votes
1 votes

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

22 votes
22 votes
3 answers
1
21 votes
21 votes
1 answer
4