Validating a string given in context free grammar in Java

How can anyone check if a string is part of context free grammar? Not only virtually, but also build an algorithm for it?

Given contextual free grammar with rules like

  • V-> v1v2
  • v1-> 1 | 1x1
  • v2-> 2 | 2x2

Obviously, this is the language 1 ^ n 2 ^ n. But how would you go about using an algorithm to check if it really is. I am trying to execute this in java.

+5
source share
1 answer

, CYK, , . O (n 3) n, ( ), CYK , , O (n 3).

, !

+7

All Articles