Is there any error in the construction of BST because I think I am correct with my logic. In the explaination BST has been constructed somewhat differently.
Print Within Range BST
hey @ap8730390
Is there any error in the construction of BST
Answer : yes
int n = scn.nextInt();
int [] arr = new int[n];
for(int i = 0; i< arr.length; i++){
arr[i]= scn.nextInt();
}
Arrays.sort(arr);// this is wrong because root Node is change
Add Node Manually . there is No need to sort array
How can you make a tree You can see my code
Thanks for help. Is there any shorter way to do this question because although my code is working now but it’s very big
- To create a tree 2. Print Preorder 3. Print Nodes in range using inorder 4. Delete Tree using postorder.
Is there any shorter way to do this question because although my code is working now but it’s very big
Answer . Nope
- Delete Tree using postorder. // no need
If you have no any doubt
Please mark your doubts as resolved in your course’s.
But I had to delete my tree, otherwise it was showing error in preorder output
Okay .
i am using only 3 operation
- create a tree 2. Print Preorder 3. Print Nodes in range
you can see my code . I have provided the solution link above