[Solved] Write Java Question 1 Write Java Program Generates Random Connected Undirected Graph Progr Q37164495

Write in JAVA
Question 1)
Write a java program that generates a random
connected undirected graph
Your program should include these steps:
1. Ask the number of vertices to the user (n)
2. Create an adjacency matrix of n * n (with undirectededges)
3. Print the matrix
4. Check if the matrix is connected (you can use DFSalgorithm)
5. If the graph is not connected make it connected
6. Print the matrix again
7. Apply DFS to find a possible spanning tree
8. Print the result (vertices and edges)
9. Apply BFS to find a possible spanning tree
10. Print the result (vertices and edges)
Question 2)
Write a java program which generates a binary tree in twoways:
1. Array-based
2. Reference-based
Question 1) (60 points) Write a java program that generates a random connected undirected graph. Your program should include these steps: 1. Ask the number of vertices to the user (n) 2. Create an adjacency matrix of n * n (with undirected edges) 3. Print the matrix 4. Check if the matrix is connected (you can use DFS algorithm) 5. If the graph is not connected make it connected 6. Print the matrix again 7. Apply DFS to find a possible spanning tree 8. Print the result (vertices and edges) 9. Apply BFS to find a possible spanning tree 10.Print the result (vertices and edges) Question 2) (40 points) Write a java program which generates a binary tree in two ways: 1. Array-based 2. Reference-based Show transcribed image text Question 1) (60 points) Write a java program that generates a random connected undirected graph. Your program should include these steps: 1. Ask the number of vertices to the user (n) 2. Create an adjacency matrix of n * n (with undirected edges) 3. Print the matrix 4. Check if the matrix is connected (you can use DFS algorithm) 5. If the graph is not connected make it connected 6. Print the matrix again 7. Apply DFS to find a possible spanning tree 8. Print the result (vertices and edges) 9. Apply BFS to find a possible spanning tree 10.Print the result (vertices and edges) Question 2) (40 points) Write a java program which generates a binary tree in two ways: 1. Array-based 2. Reference-based
Expert Answer
Answer to Write in JAVA Question 1) Write a java program that generates a random connected undirected graph Your program should in… . . .
OR

