Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
11th Edition
ISBN: 9780134694511
Author: Liang, Y. Daniel
Publisher: Pearson Education Canada
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
Using examples of your own, write short notes to explain how ArrayList and LinkedList work in Java.
please give me a code example how to do that?
Write code program (Single server queuing) in javaFx with gui to enter value (example: number of user).
I need screenshot from code
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; i
Chapter 28 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
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
- It is time for you to demonstrate your skills in a project of your own choice. You must DESIGN,ANALYSE AND CODE any method for the GENERIC MyLinkedList class that will manipulate the linkedlist. You can decide yourself what it should be following the specification below:1. Purpose: The method must make logical sense – it should be of some purpose to somebody.You should describe in the text who will use the method for which purpose.2. Clearly explain the problem. Then clearly explain how your method will solve it.3. Test program: Test the method using a wrapped class like Integer however, you will get extramarks if you can test it with the new classes you created in I_Do1 and I_Do2.arrow_forwardIt is time for you to demonstrate your skills in a project of your own choice. You must DESIGN,ANALYSE AND CODE any method for the GENERIC MyLinkedList class that will manipulate the linkedlist. You can decide yourself what it should be following the specification below:1. Purpose: The method must make logical sense – it should be of some purpose to somebody.You should describe in the text who will use the method for which purpose.2. Clearly explain the problem. Then clearly explain how your method will solve it.3. Test program: Test the method using a wrapped class like Integer wrapper class. All of this must be done using generic linked lists, and coded in java.arrow_forwardIt is time for you to demonstrate your skills in a project of your own choice. You must DESIGN,ANALYSE AND CODE any method for the GENERIC MyLinkedList class that will manipulate the linkedlist. You can decide yourself what it should be following the specification below:1. Purpose: The method must make logical sense – it should be of some purpose to somebody.You should describe in the text who will use the method for which purpose.2. Clearly explain the problem. Then clearly explain how your method will solve itarrow_forward
- Programming in Java. What would the difference be in the node classes for a singly linked list, doubly linked list, and a circular linked list? I attached the node classes I have for single and double, but I feel like I do not change enough? Also, I use identical classes for singular and circular node which does not feel right. Any help would be appreciated.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_forward
- 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.arrow_forwardBelow 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_forwardLook at the API of the Point class and find out how to construct a Point object. Write a Java program “PointTester”, that constructs two points with coordinates (3, 4) and (–3, –4). Find the distance between them, using the distance method. Print the distance, as well as the expected value. (You may draw a sketch on graph paper to find the value you will expect.) - Update your program so it randomly select coordinate points (x,y), where −50 ≤ ? ≤ 50 ??? ? ∈ [−90, 90].arrow_forward
- in java please.Create a method from the implementation perspective. Create a method where it takes in a linked chain of values and adds them in order to the front. method header:public void addToFront(ANode<T> first)arrow_forwardWrite a program in the Java language that includes: 1. A class for books, taking into account the encapsulation and getter, setter. 2. Entering books by the user using Scanner 3. LinkedList class for: (Adding a new book - Inserting a book- Searching for a book using the ISBN Number - Viewing all books,delete book). 4. Serial number increases automatically with each book that is entered. 5. Printing the names of books is as follows: Serial - ISBN - Name - PubYear - Price - Notes. 6-Design a main menu that includes: • Add Book • Insert Book • Delete Book • Search . Display . Exitarrow_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_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_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