Advertisement
Guest User

Untitled

a guest
Mar 31st, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. */
  2. public class Node {
  3.  
  4. final int contents;
  5. Node left, right;
  6. Node parent;
  7. Boolean available = true;
  8. Node(int contents, Node left, Node right) {
  9. this.contents = contents;
  10. this.left = left;
  11. if (left != null) {
  12. left.parent = this;
  13. }
  14. this.right = right;
  15. if (right != null) {
  16. right.parent = this;
  17. }
  18. }
  19. public Node copy(){
  20. return new Node(this.contents,this.left,this.right);
  21. }
  22.  
  23.  
  24.  
  25. public CustomIterator preorderIterator() {
  26. PreOrderIterator node=new PreOrderIterator(this);
  27. return node;
  28. }
  29.  
  30. public CustomIterator inorderIterator(){
  31. InOrderIterator node=new InOrderIterator(this);
  32. return node;
  33. }
  34.  
  35. public CustomIterator postorderIterator(){
  36. PostOrderIterator node=new PostOrderIterator(this);
  37. return node;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement