Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2014 | Question 5
  • Last Updated : 11 May, 2018

What is the number of steps required to derive the string ((() ()) ())

S → SS
S → (S)
S → ε

(A) 10
(B) 15
(C) 12
(D) 16


Answer: (A)

Explanation: To generate ((() ()) ()) , following steps are needed:

1) S → (S)
2) S → (SS)
3) S → ((S)S)
4) S → ((SS)S)
5) S → (((S)S))S)
6) S → (((S)(S))S)
7) S → (((S)(S))(S))  [S → ε]  
8) S → ((()(S))S)     [S → ε]
9) S → ((()())S)      [S → ε]  
10) S → ((()()))

Option (A) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :