Elementary and no so elementary Java algorithms
stringAlgorithms.SentenceRecognize Class Reference

List of all members.

Public Member Functions

 SentenceRecognize ()
boolean isSentence (String sentence)

Protected Member Functions

boolean isWord (String word)

Static Protected Attributes

static final String dictionary []

Detailed Description


This little algorithm is yet another white board interview problem that I ran into at a company named MapR. I can't think of any application for this algorithm. Hopefully it will help you, dear reader.

The MapR recruiter contacted me and got me to interview with MapR. As is the case with so many companies these days, after I took the time to interview with MapR I never heard from them (or the recruiter) again.

Sep 28, 2013

Ian Kaplan,

Definition at line 32 of file

Constructor & Destructor Documentation

stringAlgorithms.SentenceRecognize.SentenceRecognize ( )

Definition at line 39 of file

Member Function Documentation

boolean stringAlgorithms.SentenceRecognize.isSentence ( String  sentence)

Determine if a sentence, composed of a separator free set of words, is a valid sentence (e.g., entirely composed of words from the dictionary). Some examples are listed below (not all words are valid english words):

  • dropedapple : dropped apple
  • dropedith : drop edith
  • arearmarea : are arm area
  • aappledoped : a apple doped
  • hedropedtheball : he dropped the ball
  • areanaitcharm : areana it charm
sentencethe "sentence" to be tested
true if the separator free sentence is composed of words found in the dictionary, false otherwise.

Definition at line 91 of file

boolean stringAlgorithms.SentenceRecognize.isWord ( String  word) [protected]

Search for a word in the dictionary

wordthe word being searched for
true if the word is found, false otherwise

Definition at line 46 of file

Member Data Documentation

final String stringAlgorithms.SentenceRecognize.dictionary[] [static, protected]
Initial value:
 {"a", "an", "at", "attach", "attached", "he", "apple", "are", "area", 
                                                  "arean", "areana", "arm", "charm", "lever", "clever", "drop", 
                                                  "droped", "dope", "doped", "it", "the", "edith", "ball"}

Definition at line 35 of file

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables