I would like to implement CYK algorithm in C/C++, but available on various websites pseudo-code doesn't answer how to implement it efficiently. I wrote a version that uses some stl structures like map and sets, but it's very slow. I was thinking about improve my implementation by using only binary operations, but I don't know how to store my table with sets. Lets say that we have only 8 symbols for non terminals and 26 for terminals. I was thinking about using table of unsigned chars (2^8 -> 8 positions for 0-1) for storing information about productions, but I don't know how to store it.
Could you give me some help or clue?
You don't provide many details, a simple implementation (even pseudo code) could help a lot to give you hints.
From wikipedia:
for this you can use a simple string, or a vector of chars
I would store the nonterminal symbols in an array of bools std::array nonterminal {}; then since yu have characters you can initialize the position corresponding to the char, with true.
nonterminal[static_cast('C')] = true; you do the same with the terminal and you have a really fast look up mechanism.
The algorithm seems pretty straightforward after that. Just make sure not to initialize temporary values inside tight loops and you'll be fine.