Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- */
- public class Node {
- final int contents;
- Node left, right;
- Node parent;
- Boolean available = true;
- Node(int contents, Node left, Node right) {
- this.contents = contents;
- this.left = left;
- if (left != null) {
- left.parent = this;
- }
- this.right = right;
- if (right != null) {
- right.parent = this;
- }
- }
- public Node copy(){
- return new Node(this.contents,this.left,this.right);
- }
- public CustomIterator preorderIterator() {
- PreOrderIterator node=new PreOrderIterator(this);
- return node;
- }
- public CustomIterator inorderIterator(){
- InOrderIterator node=new InOrderIterator(this);
- return node;
- }
- public CustomIterator postorderIterator(){
- PostOrderIterator node=new PostOrderIterator(this);
- return node;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement