[Solved]Java Q1 Bst 1 Write Method Takes Array Parameter Contains Elements Bst Traversed Preorder Q37260240
java
Q1. BST:
1. Write a method that takes an array A, as parameter (A containsthe elements of a BST traversed in preorder) and returns thecorresponding BST.
2. Write a method to list the nodes on the path from the root to agiven node in the BST.
3. Write a recursive method to check if two BSTs are same.
4. Write a non-recursive method to check if two BSTs aresame.
5. Write a method to count the number of nodes in BST with a singlechild.
6. Write the main program to test your methods.
Q2. Design and implement a program to read information about roadsconnecting a set of cities and find the shortest path between twocities entered by the user.
Input File:
Input consists of information about the roads connecting the set ofcities. The first line of input contains 2 integer M and N whereindicated the number of cities and M the number of roads. The nextM lines contain the description of the roads. Each road isdescribed by 3 numbers S, D, L, where S and D are cities numbersand L is the distance between them.
Output:
A line containing the shortest distance to go from city S toD.
Sample input:
5 10
0 1 16
0 3 2
0 4 3.0
1 2 5
2 1 3
3 1 12
3 4 7
4 1 10
4 2 4
4 3 5
Sample output
The shortest distance between 0 and 1 is 10
Expert Answer
Answer to java Q1. BST: 1. Write a method that takes an array A, as parameter (A contains the elements of a BST traversed in preor… . . .
OR

