Skip to main content
added 364 characters in body; added 42 characters in body
Source Link
Ewan
  • 84.4k
  • 5
  • 91
  • 189

I think the structure you are looking for is a 'Trie' commonly used for auto complete, spell checking etc.

In your case a trie which is flat, ie no node has a child node, should equate to none of the words being a substring at the start or end of any of the others and hence your ablity to ommit a delimiter.

In the case of 'pop' and 'popcorn' but no 'corn' you need to check for both duplicate nodes in the trie. And nodes which are not words

Ie i have pop->corn but only one instance of each

where as if I add the word 'orn' I would have root -> pop->c->orn and root->orn but a non word node 'c'

If I add 'corn' I have root->pop->corn and root->corn. With no non words

Hmmm no thinking about it perhaps not...

I think the structure you are looking for is a 'Trie' commonly used for auto complete, spell checking etc.

In your case a trie which is flat, ie no node has a child node, should equate to none of the words being a substring at the start or end of any of the others and hence your ablity to ommit a delimiter

I think the structure you are looking for is a 'Trie' commonly used for auto complete, spell checking etc.

In your case a trie which is flat, ie no node has a child node, should equate to none of the words being a substring at the start of any of the others and hence your ablity to ommit a delimiter.

In the case of 'pop' and 'popcorn' but no 'corn' you need to check for both duplicate nodes in the trie. And nodes which are not words

Ie i have pop->corn but only one instance of each

where as if I add the word 'orn' I would have root -> pop->c->orn and root->orn but a non word node 'c'

If I add 'corn' I have root->pop->corn and root->corn. With no non words

Hmmm no thinking about it perhaps not...

Source Link
Ewan
  • 84.4k
  • 5
  • 91
  • 189

I think the structure you are looking for is a 'Trie' commonly used for auto complete, spell checking etc.

In your case a trie which is flat, ie no node has a child node, should equate to none of the words being a substring at the start or end of any of the others and hence your ablity to ommit a delimiter