@@ -0,0 +1,1906 @@
+package thirty_days_of_code;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * The height of a binary tree is the number of nodes on the largest path from%0D%0A * root to any leaf. You are given a pointer root pointing to the root of a%0D%0A * binary search tree. Return the height of the tree.%0D%0A * You only have to complete the function getHeight given in the editor.%0D%0A * %0D%0A * Input Format: %0D%0A * First line contains T, the number of test cases. Next T lines contain an%0D%0A * integer data to be added to the binary search tree.%0D%0A * %0D%0A * Output Format: %0D%0A * Output the height of the binary search tree.%0D%0A * %0D%0A * Sample Input: %0D%0A * 7%0D%0A * 3%0D%0A * 5%0D%0A * 2%0D%0A * 1%0D%0A * 4%0D%0A * 6%0D%0A * 7%0D%0A * %0D%0A * Sample Output: %0D%0A * 4%0D%0A */%0D%0Apublic class BinarySearchTrees %7B%0D%0A%0D%0A%09public static int getHeight(TNode root)%7B%0D%0A%09    %0D%0A%09    if (root == null) %7B%0D%0A%09        return 0;%0D%0A%09    %7D else %7B%0D%0A%09        return 1 + Math.max(getHeight(root.left), getHeight(root.right));%0D%0A%09    %7D%0D%0A%09%7D%0D%0A%09%0D%0A    public static TNode insert(TNode root,int data)%7B%0D%0A        if(root==null)%7B%0D%0A            return new TNode(data);%0D%0A        %7D%0D%0A        else%7B%0D%0A            TNode cur=new TNode(data);%0D%0A            if(data%3C=root.data)%7B%0D%0A                cur=insert(root.left,data);%0D%0A                root.left=cur;%0D%0A            %7D%0D%0A            else%7B%0D%0A                cur=insert(root.right,data);%0D%0A                root.right=cur;%0D%0A            %7D%0D%0A            return root;%0D%0A        %7D%0D%0A    %7D%0D%0A%09 public static void main(String args%5B%5D)%7B%0D%0A        Scanner sc=new Scanner(System.in);%0D%0A        int T=sc.nextInt();%0D%0A        TNode root=null;%0D%0A        while(T--%3E0)%7B%0D%0A            int data=sc.nextInt();%0D%0A            root=insert(root,data);%0D%0A        %7D%0D%0A        int height=getHeight(root);%0D%0A        System.out.println(height);%0D%0A        sc.close();%0D%0A    %7D%0D%0A%7D%0D%0A%0D%0Aclass TNode %7B%0D%0A    TNode left,right;%0D%0A    int data;%0D%0A    TNode(int data)%7B%0D%0A        this.data=data;%0D%0A        left=right=null;%0D%0A    %7D%0D%0A%7D

Add BinarySearchTree