ISRO Computer Science (CSE) 2015 - Question 24

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 2015

Given the following expression grammar: E -> E * F | F + E | F, F -> F - F | id. Which of the following is true?

  • A. * has higher precedence than +
  • B. - has higher precedence than *
  • C. + and - have same precedence
  • D. + has higher precedence than *

Answer: B. - has higher precedence than *

Explanation: F is lower in the parse tree (closer to leaves) for '-' operations than E is for '*'. Thus '-' binds tighter.

| | All questions of ISRO Computer Science (CSE) 2015