Show the output of the following code:
public class Test {
public static void main(String[] args) {
WeightedGraph<Character> graph = new WeightedGraph<>();
graph.addVertex(‘U’);
graph.addVertex(‘V’);
graph.addVertex(‘X’);
int indexForU = graph.getIndex(‘U’);
int indexForV = graph.getIndex(‘V’);
int indexForX = graph.getlndex(’X’);
System.out.println(“indexForU is ” + indexForU);
System.out.println(“indexForV is ” + indexForV);
System.out.println(“indexForX is ” + indexForV);
graph.addEdge(indexForU, indexForV, 3.5);
graph.addEdge(indexForV, indexForU, 3.5);
graph.addEdge(indexForU, indexForX, 2.1);
graph.addEdge(indexForX, indexForU, 2.1);
graph.addEdge(indexForV, indexForX, 3.1);
graph.addEdge(indexForX, indexForV, 3.1);
WeightedGraph<Character>.MST mst
= graph.getMinimumSpanningTree();
graph.printWeightedEdges();
System.out.println(mst.getTotalWeight{));
mst.printTree();
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 29 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
Modern Database Management
SURVEY OF OPERATING SYSTEMS
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Web Development and Design Foundations with HTML5 (8th Edition)
- Course: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java and attach output screen with program: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: classBSTNode { Node left; Node right; int data; publicBSTNode(int _data);// assign data to_data and assign left and right node to null } class BST { BSTNoderoot; public BST();// assign root to null void insert(int data);// this function insert the data in tree which maintain property of BST boolean Search(int key); this function search the data in bst and return true if key is found else return false public void EvenPrint(Node n)// this function only print the data which are even, make this function resursive public void OddPrint(Node n)// this function only print the data which are odd, make this function resursive public void PrimePrint(Node n)// this function only…arrow_forwardpackage ch08.apps;import ch08.maps.*; public class HMapDriver { public static void main(String[] args) { boolean result; HMap<String, String> test; test = new HMap<String, String>(10,0.75); /*String s = null;test.put(s,"value");test.put("s",null);System.out.println("Expect 'null':\t" + test.get("s"));System.out.println("Expect 'true':\t" + test.contains("s"));test = new ArrayListMap<String, String>();*/ System.out.println("Expect 'true':\t" + test.isEmpty()); System.out.println("Expect '0':\t" + test.size()); System.out.println("Expect 'null':\t" + test.put("1", "One")); System.out.println("Expect 'false':\t" + test.isEmpty()); System.out.println("Expect '1':\t" + test.size()); System.out.println("Expect 'One':\t" + test.put("1", "One")); System.out.println("Expect 'false':\t" + test.isEmpty()); System.out.println("Expect '1':\t" + test.size()); test.put("2", "Two"); test.put("3", "Three");…arrow_forwardQuestion 2. package sortsearchassigncodeex1; import java.util.Scanner; import java.io.*; // // public class Sortsearchassigncodeex1 { // public static void fillArray(Scanner inputFile, int[] arrIn){ int indx = 0; //Complete code { arrIn[indx] = inputFile.nextInt(); indx++; } }arrow_forward
- Kindly fix this error for me import java.io.IOException;public class MazeTest {public static void main(String[] args) throws IOException {MazeSolver solver = new MazeSolver("maze2.txt");solver.displayMaze(); // Display initial state of the mazesolver.solveMaze(); // Solve the maze using DFS}} Error: C:\Users\adamu\IdeaProjects\MazeSolver.java\src\MazeTest.java:6:15java: cannot find symbol symbol: method displayMaze() location: variable solver of type MazeSolverarrow_forwardr import java.io.IOException;Correct this error for me. public class MazeTest {public static void main(String[] args) throws IOException {MazeSolver solver = new MazeSolver("maze2.txt");solver.displayMaze(); // Display initial state of the mazesolver.solveMaze(); // Solve the maze using DFS}} Error: C:\Users\adamu\IdeaProjects\MazeSolver.java\src\MazeTest.java:6:15java: cannot find symbol symbol: method displayMaze() location: variable solver of type MazeSolverarrow_forwardJAVA PROGRAMFILL IN THE BLANKSarrow_forward
- Public class DLL{ public DLLNode first; public DLLNode last; public DLL() {this.first=Null; this.last=Null;} Public void Display() {if (first==Null) {s.o.p(“ the list is empty”);} else {for (DLLNode curr=first; curr!=Null; curr=curr.succ) {System.out.println(“the element is”+ curr.element); }} Public void AddBegining(DLLNode Node) {Node.succ=first; First.prev=Node First=Node; Node.prev=Null; if(first ==null && last==null) Last=node; } Public void Append(DLLNode Node) {Node.succ=Null; if(first==Null) {first=Node; Node.prev=Null} Public void insetAfter(int obj, DLLNode Node) {DLLNode curr=first; while((curr!=Null)&&( curr.element!=obj)) { curr=curr.succ; } If(curr.element==obj) {Node.succ=curr.succ; Curr.succ.prev=Node; Curr.succ=Node; Node.prev=curr;} Else System.out.println(“the element doesn’t exist”); Public void delete(DLLNode del) { if(first==Null) {System.out.println(“the list is empty”); } Else if(del==first)…arrow_forwardA/ find code optimization method to this code and then find type to this code 1- For(i=1;iarrow_forwardDraw the control flow graph of the code.arrow_forwardComputer Science QuestionConsider the adjacency list (list of neighbors) data structure for representing a graph. struct node{int data; node * next;};class Graph { …………private:node neighborList[30];int last;};Write a method to print the neighbors of a given node n, void Graph::print(int n){??????}arrow_forwardUML Diagrams: Course -courseName: String -students: Student [] -numberOfStudents: int +Course(courseName : String) +getCourseName() : String +addStudent (student : Student) : void +addStudent (studentName: String): void +dropStudent(studentId: int ) : void +getStudents() : Student [] +getNumberOfStudents() : int a. How many constructors does Course have? b. How many methods that are void? c. How many methods that return a value? d. What is the parameter to the method dropStudent?arrow_forwardmake this code workable import java.util.ArrayList; public class Album { private String title, artist; private int year; private ArrayList<Songs> songs; public Album() { title = ""; artist = ""; year = 0; songs = new ArrayList<>(); } public Album(String title, String artist, int year, ArrayList<Song> songs) { super(); this.title = title; this.artist = artist; this.year = year; this.songs = songs; } /** * @return the title */ public String getTitle() { return title; } /** * @param title the title to set */ public void setTitle(String title) { this.title = title; } /** * @return the artist */ public String getArtist() { return artist; } /** * @param artist the artist to set */ public void setArtist(String artist) { this.artist = artist; } /** * @return the year */ public int getYear() { return year; } /** * @param year the year to set */ public void setYear(int year) { this.year = year; } /** * @return the songs */ public ArrayList<Song>…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education