daily pastebin goal
80%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MyTreeNode a = new MyTreeNode ("a");
  2.    
  3. MyTree     tree = new MyTree (a);
  4.    
  5. e.setChild(j);
  6. e.setSibling(d);
  7.    
  8. public List getChildren ()
  9. {
  10.     List <MyTreeNode> children = new ArrayList <MyTreeNode> ();
  11.  
  12.     MyTreeNode x = this.child;
  13.  
  14.     children.add(x);
  15.  
  16.     while (x != null && x.sibling != null) {
  17.         x = x.sibling;
  18.         children.add(x);
  19.     }
  20.  
  21.     return children;
  22. }
  23.    
  24. public class Node{
  25.    String nodeName;
  26.  
  27.    Node left;
  28.    Node right;
  29.  
  30.    public Node(String nodeName, Node left, Node right){
  31.      this.nodeName = nodeName;
  32.      this.left     = left;
  33.      this.right= right;
  34.    }
  35. }
  36.    
  37. A
  38.                /
  39.               E
  40.             /  
  41.            D     J
  42.          /      /
  43.         C    H  I   K
  44.        /
  45.       B
  46.      /
  47.     G
  48.    /    
  49.   F
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top