How to take input in this question

public static void main(String[] args) {
	// TODO Auto-generated method stub
 BST t=new BST();
 Scanner sc=new Scanner(System.in);
 int test=sc.nextInt();
 while(test!=0) {
	 int n=sc.nextInt();
 int ar[]=new int[n];
 for(int i=0;i<n;i++) {
	 ar[i]=sc.nextInt();
 }
 Arrays.sort(ar);
 t.constract(ar);
 int m=sc.nextInt();
 int arr[]=new int[m];
 for(int j=0;j<m;j++) {
	 arr[j]=sc.nextInt();
 }
 for(int i=0;i<m;i++) {
	 t.delete(arr[i]);
 }
 t.preOrder();
 System.out.println();
 test--;
}
}

this is right or wrong if wrong then tell me how take input

@sksumitkumardiwaker,
Don’t sort the array before construction.

For construction use something like this:

construct(int val, node nn){
	if (nn == null) {
		Node nk = new Node();
		nk.data = val;
		root = nk;
		return;
	}
	if (nn.data > val) {
		if (nn.left != null) {
			add(val, nn.left);
		} else {
			Node nk = new Node();
			nk.data = val;
			nn.left = nk;
			return;
		}
	} else if (nn.data < val) {
       complete this on your own....
  }}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.