How can someone validate if a string is part of a context free Grammar? Not just virtually, but build an algorithm for it?
Given a context free grammar with rules such as
- V-> v1v2
- v1->1 | 1v1
- v2-> 2 | 2v2
It is obvious that this is the language 1^n 2^n. But how would you go about with an algorithm to verify if it actually is. I am trying to accomplish this in java.