Q64: Annihilator and identity operators

Question 64: An annihilator for an operator is a value such that when the operator is applied to the annihilator and some other value, the result is the annihilator. For example in arithmetic 0 is the annihilator for multiplication (0*x = 0). An identity for an operator is a value such that when the operator is applied to the identity and some other value, the result is the other value. Similarly, 0 is the identity for addition and 1 for multiplication (0+x = x and 1*x = x).

Which of the following is true for regular expressions?

  1. ∅ + L = L
  2. ∅L = ∅
  3. ∈L = L
  4. All of the above

 

Solution: ∈ is the identity for concatenation operation, and ∅ is the annihilator for concatenation and identity for union. The correct answer is option 4

Q34: Context free grammar contd.

This question is in continuation of the previous questions 29 and 30

Question #34: If we remove production 4 in the grammar mentioned in 29 , which of the following will be hampered?

A)     Production 4 is used to enforce priority, e.g. in the string 6 + 7 * 8, if we want to perform the addition first, we must use brackets in this way (6 + 7) * 8.

B)      Production 4 is used to enforce priority, e.g. in the string 6 + 7 * 8, if we want to perform the multiplication first, we must use brackets in this way 6 + (7 * 8).

C)      Production 4 is present in above grammar because it makes the strings non-ambiguous, they don’t add any power to the language.

D)     None of the above.

 

Solution:

Multiplication anyways has higher priority than addition operator, brackets are required in cases where we want to reverse the priority. Hence, the correct answer is A