title: How to print a given node from a Binary Search Tree?
body: <p>How do I print out a given node from my binary search tree using a method called PrintNodes.</p>
  
  <p>Here is my Node class:</p>
  
  <pre><code>public class Node
  {
      public string data;
      public Node left;
      public Node right;
  
      public Node(string data)
      {
          this.data = data;
      } 
  }
  </code></pre>
  
  <p>And here is my Binary Search Tree Class:</p>
  
  <pre><code>class BinarySearchTree
  {
      public Node root, current;
  
      public BinarySearchTree()
      {
          this.root = null;
      }
  
      public void AddNode(string a) // code to insert nodes to the binary search tree 
      {
          Node newNode = new Node(a); //create a new node 
          if (root == null) // if the tree is empty new node will be the root node 
              root = newNode;
          else
          {
              Node previous;
              current = root;
              while (current != null)
              {
                  previous = current;
                  if (string.Compare(a,  current.data) &lt; 0) //if the new node is less than the current node 
                  {
                      current = current.left;
                      if (current == null)
                          previous.left = newNode;
                  }
                  else //if the new node is greater than the current node 
                  {
                      current = current.right;
  
                      if (current == null)
                          previous.right = newNode;
                  }
              }
          }
      }  
  </code></pre>
  
  <p>This is the what I have so far for my PrintNodes method, but I just realised that its not actually printing the given node its just printing the string that I pass into the method(I'm really new to this as you can see)</p>
  
  <pre><code> public String PrintNodes(string a)
      {
          string Output = "";
  
          if (a != null)
          {
              Output += "Node: " + a;
          }
          else
          {
              Output += "There is no node " + a;
          }
  
  
          return Output;
      }
  </code></pre>
  
  <p>I know I have to somehow compare the string that is passed into the method to the node I am trying to print but I have no clue what to do my mind has gone blank.</p>