public class BinNode<T> {
private BinNode<T> right;
public BinNode(BinNode<T> left, T x, BinNode<T> right) {
public void setValue(T x) {
public BinNode<T> getLeft() {
public BinNode<T> getRight() {
public void setLeft(BinNode<T> left) {
public void setRight(BinNode<T> right) {
return this.right != null;
return this.left != null;
public override String ToString() {
return this.value.ToString();
public Node(T value, Node<T> next)
public void SetValue(T value)
public void SetNext(Node<T> next)
public static bool Exist(BinNode<int> t, int x){
return Exist(t.getLeft(),x) || Exist(t.getRight(),x);
public static Node<int> Check(BinNode<int> t1, BinNode<int> t2){
Node<int> first = new Node<int>(-1);
first = Check(t1,t2,first);
public static Node<int> Check(BinNode<int> t1, BinNode<int> t2, Node<int> list){
if(!Exist(t2,t1.getValue())){
list.SetNext(new Node<int>(t1.getValue(),list.GetNext()));
Check(t1.getLeft(), t2, list);
Check(t1.getRight(),t2, list);
public static void Main()
Console.WriteLine("Hello World");