Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider the grammar defined by the following... Start Learning for Free
Consider the grammar defined by the following production rules, with two operators ∗ and +
S --> T * P
T --> U | T * U
P --> Q + P | Q
Q --> Id
U --> Id
 
Q. Which one of the following is TRUE?
  • a)
    + is left associative, while ∗ is right associative
  • b)
    + is right associative, while ∗ is left associative
  • c)
    Both + and ∗ are right associative
  • d)
    Both + and ∗ are left associative
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
Consider the grammar defined by the following production rules, with t...
From the grammar we can find out associative by looking at grammar.
Let us consider the 2nd production T -> T * U
T is generating T*U recursively (left recursive) so * is left associative.
Similarly
P -> Q + P
Right recursion so + is right associative. So option B is correct.
NOTE: Above is the shortcut trick that can be observed after drawing few parse trees. One can also find out correct answer by drawing the parse tree.
View all questions of this test
Most Upvoted Answer
Consider the grammar defined by the following production rules, with t...
Explanation:

  • The given grammar has two operators, i.e., * and |.

  • The operator * has higher precedence than |.

  • Precedence of * is higher than |, so * is right associative.

  • Precedence of | is lower than *, so | is left associative.

  • Therefore, the correct option is B, where * is right associative and | is left associative.

Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer?
Question Description
Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer?.
Solutions for Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer?, a detailed solution for Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? has been provided alongside types of Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider the grammar defined by the following production rules, with two operators ∗ and +S --> T * PT --> U | T * UP --> Q + P | QQ --> IdU --> IdQ. Which one of the following is TRUE?a)+ is left associative, while ∗ is right associativeb)+ is right associative, while ∗ is left associativec)Both + and ∗ are right associatived)Both + and ∗ are left associativeCorrect answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev