title: Binary tree variable type issue
body: <p>I'm having trouble with a method I wrote to insert string words into a binary tree. The below code is the method in question. Basically, the word is inserted if it is not yet in the tree (as a <code>BinaryTreeNode</code>), and if it is in the tree, its frequency (count variable within <code>BinaryTreeNode</code>) is increased by one. My problem is with the temporary variable <code>searchWord</code>. Defining it as a <code>String</code> creates a type mismatch and a statement that says <code>getFrequency()</code> is not defined for type <code>String</code>. The generic type <code>T</code> is only there as a placeholder - it too does not work. What should it therefore be defined as?</p>
  
  <p>buildBinaryTree method:</p>
  
  <pre><code>public static void buildBinaryTree(String word) {
      //if word is already in tree
      if(wordTree.contains(word)) {
          //find existing word node
          T searchWord = wordTree.find(word);  //problem here
  
          //increment frequency by 1
          searchWord.setFrequency(searchWord.getFrequency() + 1);
      } else {
          //add word to tree
          System.out.println(word);
          wordTree.addElement(word);
      }
  }
  </code></pre>
  
  <p>BinaryTreeNode constructor:</p>
  
  <pre><code>/**
   * Creates a new tree node with the specified data.
   * @param obj the element that will become a part of the new tree node
   */
  BinaryTreeNode(T obj) {
     element = obj;
     left = null;
     right = null;
     frequency = 1;
  }
  </code></pre>
  
  <p>Frequency get/set methods:</p>
  
  <pre><code>/**
   * Gets the frequency.
   * @return the frequency
   */
  public int getFrequency() {
     return frequency;
  }
  
  /**
   * Sets the frequency.
   * @param frequency the frequency to set
   */
  public void setFrequency(int frequency) {
     this.frequency = frequency;
  }
  </code></pre>