title: fastest way to do keyword search in large text in C/C++
body: <p>Say I have 100 keywords (that can include spaces) and I need to find out how many times they occur in a big piece of text. What would the fast way be to accomplish this?</p>
  
  <p>My current idea is as follows:</p>
  
  <ul>
  <li>turn the keywords into a suffix tree</li>
  <li>walk through the text following the nodes and whenever a char does not occur (i.e. node->next == NULL) in the suffix tree, skip to next word and search again</li>
  </ul>
  
  <p>The suffix tree struct would look something like this:</p>
  
  <pre><code>struct node {
     int count; //number of occurences (only used at leaf node)
     /* for each lower-case char, have a pointer to either NULL or next node */
     struct node *children[26];
  };
  </code></pre>
  
  <p>I am sure there is a faster way to do this, but what is it? Space efficiency is not really a big deal for this case (hence the children array for faster lookup), but time efficiency really is. Any suggestions?</p>