Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

ISRO | ISRO CS 2014 | Question 5

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 11 May, 2018
Like Article
Save Article
Similar Reads