bartleby

Videos

Textbook Question
Book Icon
Chapter 29.5, Problem 29.5.7CP

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.getIndex(‘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>.ShortestPathTree tree =

      graph.getShortestPath(1);

      graph.printWeightedEdges();

      tree.printTree();

  }

}

Blurred answer
Students have asked these similar questions
public class CustomLinkedList {      public static int findMax(IntNode headObj) {      /* Type your code here */            }      public static void main(String[] args) {      IntNode headObj;       IntNode currObj;      IntNode lastObj;      int i;       int max;            // Create head node      headObj = new IntNode(-1);       lastObj = headObj;            // Add nodes to the list      for (i = 0; i < 20; ++i) {          currObj = new IntNode(i);                  lastObj.insertAfter(currObj);          lastObj = currObj;      }                max = findMax(headObj);      System.out.println(max);   }}
Question 37 public static void main(String[] args) { Dog[] dogs = { new Dog(), new Dog()}; for(int i = 0; i >>"+decision()); } class Counter { private static int count; public static void inc() { count++;} public static int getCount() {return count;} } class Dog extends Counter{ public Dog(){} public void wo(){inc();} } class Cat extends Counter{ public Cat(){} public void me(){inc();} } The Correct answer: Nothing is output O 2 woofs and 5 mews O 2 woofs and 3 mews O 5 woofs and 5 mews O
In C++   class rectangleType { public:     void setLengthWidth(double x, double y); //Sets the length = x; width = y;     void print() const; //Output length and width     double area(); //Calculate and return the area of the rectangle (length*width)     double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private:     double length;     double width; };    Declare an instance of rectangleType.

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Introduction to Big O Notation and Time Complexity (Data Structures & Algorithms #7); Author: CS Dojo;https://www.youtube.com/watch?v=D6xkbGLQesk;License: Standard YouTube License, CC-BY