Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This would seem to be the sort of thing for which a hashtable would be perfect. Storage and retrieval of hashtable entries is possible in O(1) time, and can be used quite effectively here. I would recommend trying something like the following algorithm:</p> <ol> <li>Create a <code>Dictionary&lt;string, int&gt;</code> (this is effectively a generic hashtable, available from .NET 2.0 onwards). This will be used to keep track of the occurrences of each keywords (the value will act as a bit field).</li> <li><p>Load each text file and read all the keywords, setting the appropiate bit for the corresponding text file in which the keyword is found. Example:</p> <pre><code>dict[keyword] |= (1 &lt;&lt; curTextFileIndex); </code></pre> <p>where <code>curTextFileIndex</code> would vary from 0 to 3 in your case.</p></li> <li>Iterate over all entries in the dictionary, looking for the appropiate value (bit field). In your case, because you are looking for a keyword that appears in the <em>first two</em> files but <em>not the last two</em>, the value you want to search for is 0011 (or 3 in decimal). Find this entry and you have your keyword.</li> </ol> <p>Unless I'm mistaken, this algorithm runs in O(n) time, where n is the total number of keywords in all your text files. I don't think you're going to get better than that, truthfully.</p> <p>Hope that helps. Let me know if you need a few more details...</p> <p><strong>Edit</strong>: Hrmm... I seemed to have missed the bit about your "keywords" possibly containing more than one actual word. If these "keywords" are known to be shorted than a certain (lowish) number of words, then I think this solution may still be viable with small modifications. Otherwise, you'll need something a bit more clever, it would appear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload