Program: 88171
Project: 88171
Buggy source:
/** 
 * Add a word to this dictionary. The bigrams, if any, have to be in the dictionary already. If they aren't, an exception is thrown.
 * @param word the word, as an int array.
 * @param frequency the frequency of the word, in the range [0..255].
 * @param bigrams an optional list of bigrams for this word (null if none).
 */
private void add(int[] word,int frequency,ArrayList<WeightedString> bigrams){
  assert(frequency >= 0 && frequency <= 255);
  Node currentNode=mRoot;
  int charIndex=0;
  CharGroup currentGroup=null;
  int differentCharIndex=0;
  int nodeIndex=findIndexOfChar(mRoot,word[charIndex]);
  while (CHARACTER_NOT_FOUND != nodeIndex) {
    currentGroup=currentNode.mData.get(nodeIndex);
    differentCharIndex=compareArrays(currentGroup.mChars,word,charIndex);
    if (ARRAYS_ARE_EQUAL != differentCharIndex && differentCharIndex < currentGroup.mChars.length)     break;
    if (null == currentGroup.mChildren)     break;
    charIndex+=currentGroup.mChars.length;
    if (charIndex >= word.length)     break;
    currentNode=currentGroup.mChildren;
    nodeIndex=findIndexOfChar(currentNode,word[charIndex]);
  }
  if (-1 == nodeIndex) {
    final int insertionIndex=findInsertionIndex(currentNode,word[charIndex]);
    final CharGroup newGroup=new CharGroup(Arrays.copyOfRange(word,charIndex,word.length),bigrams,frequency);
    currentNode.mData.add(insertionIndex,newGroup);
    checkStack(currentNode);
  }
 else {
    if (differentCharIndex == currentGroup.mChars.length) {
      if (charIndex + differentCharIndex >= word.length) {
        if (currentGroup.mFrequency > 0) {
          throw new RuntimeException("String_Node_Str" + new String(word,0,word.length));
        }
 else {
          final CharGroup newNode=new CharGroup(currentGroup.mChars,bigrams,frequency,currentGroup.mChildren);
          currentNode.mData.set(nodeIndex,newNode);
          checkStack(currentNode);
        }
      }
 else {
        final CharGroup newNode=new CharGroup(Arrays.copyOfRange(word,charIndex + differentCharIndex,word.length),bigrams,frequency);
        currentGroup.mChildren=new Node();
        currentGroup.mChildren.mData.add(newNode);
      }
    }
 else {
      if (0 == differentCharIndex) {
        if (0 != frequency) {
          if (0 < currentGroup.mFrequency) {
            throw new RuntimeException("String_Node_Str" + currentGroup.mFrequency + "String_Node_Str"+ new String(word,0,word.length));
          }
          final CharGroup newGroup=new CharGroup(word,currentGroup.mBigrams,frequency);
          currentNode.mData.set(nodeIndex,newGroup);
        }
      }
 else {
        Node newChildren=new Node();
        final CharGroup newOldWord=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,differentCharIndex,currentGroup.mChars.length),currentGroup.mBigrams,currentGroup.mFrequency,currentGroup.mChildren);
        newChildren.mData.add(newOldWord);
        final CharGroup newParent;
        if (charIndex + differentCharIndex >= word.length) {
          newParent=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,0,differentCharIndex),bigrams,frequency,newChildren);
        }
 else {
          newParent=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,0,differentCharIndex),null,-1,newChildren);
          final CharGroup newWord=new CharGroup(Arrays.copyOfRange(word,charIndex + differentCharIndex,word.length),bigrams,frequency);
          final int addIndex=word[charIndex + differentCharIndex] > currentGroup.mChars[differentCharIndex] ? 1 : 0;
          newChildren.mData.add(addIndex,newWord);
        }
        currentNode.mData.set(nodeIndex,newParent);
      }
      checkStack(currentNode);
    }
  }
}

Fixed version (ground truth):
/** 
 * Add a word to this dictionary. The bigrams, if any, have to be in the dictionary already. If they aren't, an exception is thrown.
 * @param word the word, as an int array.
 * @param frequency the frequency of the word, in the range [0..255].
 * @param bigrams an optional list of bigrams for this word (null if none).
 */
private void add(int[] word,int frequency,ArrayList<WeightedString> bigrams){
  assert(frequency >= 0 && frequency <= 255);
  Node currentNode=mRoot;
  int charIndex=0;
  CharGroup currentGroup=null;
  int differentCharIndex=0;
  int nodeIndex=findIndexOfChar(mRoot,word[charIndex]);
  while (CHARACTER_NOT_FOUND != nodeIndex) {
    currentGroup=currentNode.mData.get(nodeIndex);
    differentCharIndex=compareArrays(currentGroup.mChars,word,charIndex);
    if (ARRAYS_ARE_EQUAL != differentCharIndex && differentCharIndex < currentGroup.mChars.length)     break;
    if (null == currentGroup.mChildren)     break;
    charIndex+=currentGroup.mChars.length;
    if (charIndex >= word.length)     break;
    currentNode=currentGroup.mChildren;
    nodeIndex=findIndexOfChar(currentNode,word[charIndex]);
  }
  if (-1 == nodeIndex) {
    final int insertionIndex=findInsertionIndex(currentNode,word[charIndex]);
    final CharGroup newGroup=new CharGroup(Arrays.copyOfRange(word,charIndex,word.length),bigrams,frequency);
    currentNode.mData.add(insertionIndex,newGroup);
    checkStack(currentNode);
  }
 else {
    if (differentCharIndex == currentGroup.mChars.length) {
      if (charIndex + differentCharIndex >= word.length) {
        if (currentGroup.mFrequency > 0) {
          throw new RuntimeException("String_Node_Str" + new String(word,0,word.length));
        }
 else {
          final CharGroup newNode=new CharGroup(currentGroup.mChars,bigrams,frequency,currentGroup.mChildren);
          currentNode.mData.set(nodeIndex,newNode);
          checkStack(currentNode);
        }
      }
 else {
        final CharGroup newNode=new CharGroup(Arrays.copyOfRange(word,charIndex + differentCharIndex,word.length),bigrams,frequency);
        currentGroup.mChildren=new Node();
        currentGroup.mChildren.mData.add(newNode);
      }
    }
 else {
      if (0 == differentCharIndex) {
        if (0 != frequency) {
          if (0 < currentGroup.mFrequency) {
            throw new RuntimeException("String_Node_Str" + currentGroup.mFrequency + "String_Node_Str"+ new String(word,0,word.length));
          }
          final CharGroup newGroup=new CharGroup(word,currentGroup.mBigrams,frequency,currentGroup.mChildren);
          currentNode.mData.set(nodeIndex,newGroup);
        }
      }
 else {
        Node newChildren=new Node();
        final CharGroup newOldWord=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,differentCharIndex,currentGroup.mChars.length),currentGroup.mBigrams,currentGroup.mFrequency,currentGroup.mChildren);
        newChildren.mData.add(newOldWord);
        final CharGroup newParent;
        if (charIndex + differentCharIndex >= word.length) {
          newParent=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,0,differentCharIndex),bigrams,frequency,newChildren);
        }
 else {
          newParent=new CharGroup(Arrays.copyOfRange(currentGroup.mChars,0,differentCharIndex),null,-1,newChildren);
          final CharGroup newWord=new CharGroup(Arrays.copyOfRange(word,charIndex + differentCharIndex,word.length),bigrams,frequency);
          final int addIndex=word[charIndex + differentCharIndex] > currentGroup.mChars[differentCharIndex] ? 1 : 0;
          newChildren.mData.add(addIndex,newWord);
        }
        currentNode.mData.set(nodeIndex,newParent);
      }
      checkStack(currentNode);
    }
  }
}