Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li>The simplest solution is: <b>client side</b> only accept the input, then send a request to <b>server side</b>, and the <b>server side</b> return the output to the <b>client side</b>. <li>Another way is make the application offline: <ol> <li>The list of Japanese words should be <b>sorted in lexicographic order</b>, so does the other two lists. <li>As Japanese have 50 letters, then the list can be split into 50 * 50 parts according to the first two letters of a word. So the <b>key point</b> is that: prepare an 50 * 50 array, recording the <b>offsets</b> corresponding to the start position of the first two letters in the file. If use 32bit integer to store <b>offsets</b>, it will cost 10KB. <li>For each Japanese word, store the <b>offsets</b> in the other two lists. For convenience, the two lists can be combined together. If use 32bit integer to store <b>offsets</b>, and you have 150000 entries, it will increase the data size by 600KB. <li>Keep the array of <b>offsets</b> in memory, when input a Japanese word, first find out the <b>offset</b> according to the first two letters, then read all the Japanese words starting with the first two letters. Cause you have 150000 entries, so in average the number of words starting with the same two letters is 60. And a <b>memory page</b> is 4KB, enough for 60 words, so only 1 <b>IO</b> is needed. After find the <b>offsets</b> in the other two lists, read the corresponding contents. So, only 2 <b>IO</b> is needed in a search operation. And the calculation cost is small too, the memory cost is also very low. </ol> </ul>
 

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