package cf1;

public class Node extends Weight {
	Node parent;
	Node left;
	Node right;

	public Node() {
		super(0);
	}
	
	public Node(Node left, Node right) {
		super(left.weight() + right.weight());
		this.left = left;
		this.right = right;
		this.left.parent = this;
		this.right.parent = this;
	}
	
	public String encode() {
		if(parent == null)
			return "";
		else
			return parent.encode() + (parent.left == this ? "0" : "1");
	}
}
