title: Binary Search Tree using char type
body: <p>I understand Binary Search Tree  on integers ,because i know the left child must be less then the node,and right child must be greater then the node ,when it comes to "char" or "string" type ,its totally different case,we can't say ( 'a' &lt; 'b' ) or any other logical operations .
  how can i compare the char values?!</p>
  
  <p>This is my Binary Tree   <a href="http://share.pho.to/89JtW" rel="nofollow">http://share.pho.to/89JtW</a> i couldn't work because each time i insert to my code.all nodes are inserted to the right of sub-node  .         </p>
  
  <p>the nodes represent a pages ,i want to check each page  to detect if user is human or spambot .</p>
  
  <p>each page can be linked to another 2 pages. A human will traverse on the
  webpage in a way that it will be able to go to the previous page or one of the next two pages that they  are linked to. Otherwise, they will be categorized as spambot.</p>
  
  <p>And this code i trying to implement </p>
  
  <pre><code>    package stringBtree;
  
  public class StringBinaryTreeSample {
    public static void main(String[] args)
      {
    new StringBinaryTreeSample().run();
    }
    static class Node 
     {
    Node left;
    Node right;
    char  value;
    public Node(char value) {
    this.value = value;
    }
    }
    public void run() {
    Node rootnode = new Node('A');
    System.out.println("Building tree with rootvalue " + rootnode.value);
    System.out.println("================================="); 
    insert(rootnode, 'b' );
    insert(rootnode, 'd' );
    insert(rootnode, 'c');
    insert(rootnode, 'd');
    insert(rootnode, 'e' );
    insert(rootnode, 'f');
    insert(rootnode, 'g');
    insert(rootnode, 'h');
    insert(rootnode, 'i');
    insert(rootnode, 'j');
    insert(rootnode, 'k');
    insert(rootnode, 'l');
    insert(rootnode, 'm');
    insert(rootnode, 'n');
    insert(rootnode, 'o');
    insert(rootnode, 'p');
    insert(rootnode, 'q');
    System.out.println("\n\nTraversing tree in order");
    System.out.println("=================================");
    printInOrder(rootnode);
    }
    public void insert(Node node, char value) {
      if (value &lt; node.value) {
  
      if (node.left != null) {
      insert(node.left, value);
      } else {
      System.out.println("  Inserted " + value +   " to left of node " + node.value);
      node.left = new Node(value);
      }
  
      } else if (value &gt; node.value) {
          if (node.right != null) {
          insert(node.right, value);
          } else {
          System.out.println("  Inserted " + value + "  to right of node " + node.value);
          node.right = new Node(value);
          }
       }
    }
    public void printInOrder(Node node) {
      if (node != null) {
      printInOrder(node.left);
      System.out.println("  Traversed " + node.value);
      printInOrder(node.right);
      }
    }
  }
  </code></pre>