java - How might an algorithm search for a phrase within a large file? -


let's have large text file (few mb gb) of random text, consisting of lowercase letters, no spaces. however, appends string somewhere in middle of (consisting of lowercase letters, no spaces) of words english language.

how go finding string , says, given not know string supposed (only it's in english, , not random text)? can use dictionary of english words.

build dictionary trie , traverse file. o(n) time in size of file (i believe o(file size * trie depth) in worst case) , o(1) memory (fixing size of dictionary , assuming small largest word). streamable , ram-efficient, scale to, say, terabyte of data gigabyte of ram.


Comments

Popular posts from this blog

android - Automated my builds -

ruby on rails - Difference between "Redmine on Heroku" and "Installing Redmine" documentation -

c# - Create a custom control in Corel Draw X6 using only VSTA -