public Node head=new Node();
public void NodeInsertion(Node parent,Node child)
if(parent.data>=child.data&&parent.left==null)
else if(parent.data<child.data&&parent.right==null)
if(parent.data>=child.data)
NodeInsertion(parent.left,child);
NodeInsertion(parent.right,child);
public Node TreeConstruction(int input)
NodeInsertion(head,temp);
public void AscendingOrder(Node temp,int key,ref int flag)
AscendingOrder(temp.left,key,ref flag);
Console.Write(temp.data +" ");
AscendingOrder(temp.right,key,ref flag);
public void DescendingOrder(Node temp)
DescendingOrder(temp.right);
Console.Write(temp.data +" ");
DescendingOrder(temp.left);
Console.WriteLine("Enter node value:");
input=Convert.ToInt32(Console.ReadLine());
current=this.TreeConstruction(input);
Console.WriteLine("enter element to search:");
key=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Elements in Ascending order are:");
this.AscendingOrder(current,key,ref flag);
Console.WriteLine("\nElements in Descending order are:");
this.DescendingOrder(current);
Console.WriteLine("\nRegarding Searching:\nSearch is UnSuccessful");
Console.WriteLine("\nRegarding Searching:\nSearch is Successful");
public static void Main()