Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 28.4, Problem 28.4.2CP
Program Plan Intro
Given code in “Listing 28.2”:
The code is to demonstrate the vertices and edges of the graph. The program can display size of the graph, index value of vertices, and edges.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Java
Given main(), complete the SongNode class to include the printSongInfo() method. Then write the Playlist class' printPlaylist() method to print all songs in the playlist. DO NOT print the dummy head node.
The first image is the main question, the second image is the directions for the program. The program has to be written in Java.
Modify the GeometricObject class to implement the Comparable interface and define a static max
method in the GeometricObject class for finding the larger of two GeometricObject objects. Draw
the UML diagram and implement the new GeometricObject class. Write a test program that uses
the max method to find the larger of two circles, the larger of two rectangles.using java programming
Chapter 28 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 28.2 - What is the famous Seven Bridges of Knigsberg...Ch. 28.2 - Prob. 28.2.2CPCh. 28.2 - Prob. 28.2.3CPCh. 28.2 - Prob. 28.2.4CPCh. 28.3 - Prob. 28.3.1CPCh. 28.3 - Prob. 28.3.2CPCh. 28.4 - Prob. 28.4.1CPCh. 28.4 - Prob. 28.4.2CPCh. 28.4 - Show the output of the following code: public...Ch. 28.4 - Prob. 28.4.4CP
Ch. 28.5 - Prob. 28.5.2CPCh. 28.6 - Prob. 28.6.1CPCh. 28.6 - Prob. 28.6.2CPCh. 28.7 - Prob. 28.7.1CPCh. 28.7 - Prob. 28.7.2CPCh. 28.7 - Prob. 28.7.3CPCh. 28.7 - Prob. 28.7.4CPCh. 28.7 - Prob. 28.7.5CPCh. 28.8 - Prob. 28.8.1CPCh. 28.8 - When you click the mouse inside a circle, does the...Ch. 28.8 - Prob. 28.8.3CPCh. 28.9 - Prob. 28.9.1CPCh. 28.9 - Prob. 28.9.2CPCh. 28.9 - Prob. 28.9.3CPCh. 28.9 - Prob. 28.9.4CPCh. 28.10 - Prob. 28.10.1CPCh. 28.10 - Prob. 28.10.2CPCh. 28.10 - Prob. 28.10.3CPCh. 28.10 - If lines 26 and 27 are swapped in Listing 28.13,...Ch. 28 - Prob. 28.1PECh. 28 - (Create a file for a graph) Modify Listing 28.2,...Ch. 28 - Prob. 28.3PECh. 28 - Prob. 28.4PECh. 28 - (Detect cycles) Define a new class named...Ch. 28 - Prob. 28.7PECh. 28 - Prob. 28.8PECh. 28 - Prob. 28.9PECh. 28 - Prob. 28.10PECh. 28 - (Revise Listing 28.14, NineTail.java) The program...Ch. 28 - (Variation of the nine tails problem) In the nine...Ch. 28 - (4 4 16 tails problem) Listing 28.14,...Ch. 28 - (4 4 16 tails analysis) The nine tails problem in...Ch. 28 - (4 4 16 tails GUI) Rewrite Programming Exercise...Ch. 28 - Prob. 28.16PECh. 28 - Prob. 28.17PECh. 28 - Prob. 28.19PECh. 28 - (Display a graph) Write a program that reads a...Ch. 28 - Prob. 28.21PECh. 28 - Prob. 28.22PECh. 28 - (Connected rectangles) Listing 28.10,...Ch. 28 - Prob. 28.24PECh. 28 - (Implement remove(V v)) Modify Listing 28.4,...Ch. 28 - (Implement remove(int u, int v)) Modify Listing...
Knowledge Booster
Similar questions
- Below is Lexer.java, Token.java, StringHandler.java, and Main.java. I need help in writing test cases. Please write unit tests for lexer.java and make sure to show the full code with the screenshot of the output. Make sure to include the test cases as well. Lexer.java import java.util.LinkedList; public class Lexer { private StringHandler stringHandler; private int lineNumber; private int charPosition; public Lexer(String input) { stringHandler = new StringHandler(input); lineNumber = 1; charPosition = 0; } public LinkedList<Token> lex() { LinkedList<Token> tokens = new LinkedList<>(); while (!stringHandler.isDone()) { char c = stringHandler.peek(0); if (c == ' ' || c == '\t') { stringHandler.swallow(1); charPosition++; } else if (c == '\n') { tokens.add(new Token(TokenType.SEPARATOR, lineNumber,…arrow_forwardJava I have a list of integers from 1 to 90, and I have 90 labels in scenebuilder. I want to give each label a value from that list. Is there a simple way to do this?arrow_forwardWhat is a HashMap? What is its purpose and how do you use it? Answer these questions in writing, and use the Java library documentation of Map and HashMap for your responses. Note that you will find it hard to understand everything, as the documentation for these classes is not very good. We will discuss the details later in this chapter, but see what you can find out on your own before reading on.arrow_forward
- In your workshop project create a new Java class (BasicArrayList) and convert the above code to work for ArrayLists. 1. You will need to import at least one package, but you do not need to import java.lang, which is the fundamental Java package (the classes you automatically get when you write Java programs). 2. Convert the first for-loop first. Don't forget you cannot use the ArrayList method to control the for-loop (so just use the number 4). 3. Convert the last for-loop next, to view the contents of your ArrayList. 4. Convert the middle for-loop last. You may want to convert the one line of array code to two lines of ArrayList code. 5. Finally, before the last for-loop, add a new element (0) to position 0 of the ArrayList. You should print the contents of the modified ArrayList. Here is a quick review of how array elements are modified and accessed: 1. public class BasicArray{ 2. public static void main(String[] args) int[] basic = new int[4]; for (int i=0; iarrow_forwardJava. Refer to screenshot. There is starter code. I need help with the method. public class LinkedList {Node head;Node tail; protected class Node{String data;Node next;} public void addLast(String s){//Complete the method here} public String toString(){ String result = ""; Node n = head;while(n != null){result += n.data + " -> ";n = n.next;} return result;} } //DO NOT MODIFY THIS CLASS//All work must be done in the LinkedList.java classimport java.util.Scanner; public class P1 {public static void main(String[] args) {Scanner kb = new Scanner(System.in);int numNames = kb.nextInt(); LinkedList list = new LinkedList();for (int i = 0; i < numNames ; i++) {list.addLast(kb.next());System.out.println(list);}}}arrow_forwardYou will implement some methods in the UndirectedGraph class. The UndirectedGraph class contains two nested classes, Vertex and Node, you should NOT change these classes. The graph will store a list of all the vertices in the graph. Each vertex has a pointer to its adjacent vertices. To get started, import the starter file, Undirected.java into the graphs package you create in a new Java Project. Please do not change any of the method signatures in the class, but you can add any helper methods you deem necessary. Implement the methods described below. You are free to test your code however you prefer. Vertex Class (DO NOT EDIT)The vertex class holds information about the vertices in the graph. It has an int val, a Vertex next that refers to the next vertex in the list of vertices (not necessarily an adjacent vertex), and a Node edge that starts the list of adjacent vertices. Node Class (DO NOT EDIT)This is a simple class to represent an adjacency list of a vertex in the graph.…arrow_forwardYou will implement some methods in the UndirectedGraph class. The UndirectedGraph class contains two nested classes, Vertex and Node, you should NOT change these classes. The graph will store a list of all the vertices in the graph. Each vertex has a pointer to its adjacent vertices. To get started, import the starter file, Undirected.java into the graphs package you create in a new Java Project. Please do not change any of the method signatures in the class, but you can add any helper methods you deem necessary. Implement the methods described below. You are free to test your code however you prefer. Vertex Class (DO NOT EDIT)The vertex class holds information about the vertices in the graph. It has an int val, a Vertex next that refers to the next vertex in the list of vertices (not necessarily an adjacent vertex), and a Node edge that starts the list of adjacent vertices. Node Class (DO NOT EDIT)This is a simple class to represent an adjacency list of a vertex in the graph.…arrow_forwardyou get setup to work with graphs.Create a Graph class to store nodes and edges or download a Graph librarysuch as JUNG. Use it to implement Breadth First Search and Depth First SearchFollow the video from class if you need a reference.arrow_forwardWhat is annonmyous inner class in Java. Give an example.arrow_forwardI got errors in parser.java. How to create methods in TokenHandler.java for getCurrentToken(), consumeToken(), getLastMatchedToken()? Please create these methods in TokenHandler.java. Fix the error for programNode that is attached. Below is TokenHandler.java TokenHandler.java import java.util.LinkedList; import java.util.Optional; import mypack.Token.TokenType; public class TokenHandler { private LinkedList<Token> tokens;// List of tokens public TokenHandler(LinkedList<Token> tokens) { this.tokens = tokens; } public Optional<Token> Peek(int j) { if (j < tokens.size()) { return Optional.of(tokens.get(j)); } else { return Optional.empty(); } } public boolean MoreTokens() { return !tokens.isEmpty(); } public Optional<Token> MatchAndRemove(TokenType t) { if (MoreTokens() && Peek(0).get().getType() == t) { return…arrow_forwardWhat is annonmyous inner class in Java. Explain with a proper example code.arrow_forwardI need help solving this in JAVAarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education