Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 28, Problem 28.4PE
Program Plan Intro

Find connected components

Program Plan:

Exercise.java:

  • Import the required packages.
  • Create a class “Exercise”:
    • Define the main method
      • Define and declare the vertices.
      • Define and declare the edges.
      • New graph gets created.
      • Perform depth first search on the list.
      • Display the connected components of the graph.
  • Define and create the class “MyGraph”
    • Create a new constructor.
    • New graph gets using the constructor.
    • Method to find “getConnectedComponents()” gets created.
      • New list gets created.
      • Loop that iterates to add the vertices into the list.
      • Loop that iterates to add the neighbor vertices into the list.
      • Loop that iterates to perform a depth first search.
      • Add the values to the list.
      • Remove all the values from the list.
      • Finally return the list.

UnweightedGraph.java:

  • Import the required packages.
  • Create a class “UnweightedGraph”:
    • New list for the vertices gets created.
    • New list for the neighbor node gets created.
    • Create an empty constructor.
    • Method to create new graph gets created and adjacency list gets created.
    • Method to create an adjacency list gets created.
    • Method to return the size of the vertices.
    • Method to return the index of the vertices gets defined.
    • Method to gets the neighbor node gets defined.
    • Method to return the degree of the vertices gets created.
    • Method to print the Edges gets created.
    • New to clear the graph gets created.
    • Method to add vertex gets created.
    • Method to add edge gets created.
    • Method to perform the depth first search gets defined.
    • Method to perform breadth first search gets defined.
      • Search tree gets returned.
  • Create a class “SearchTree”
    • Define the method to return the root.
    • Method to return the parent of the vertices
    • Method to return the search order gets defined.
    • Method to return the number of vertices found gets defined.
    • Method to get the path of the vertices gets defined.
      • Loop to validate the path gets defined.
      • Path gets returned.
    • Method to print the path gets defined.
    • Method to print the tree gets defined.
      • Display the edge.
      • Display the root.
      • Condition to validate the parent node to display the vertices gets created.

Edge.java

  • Create a class “Edge”
    • Define and declare the required variables.
    • Constructor gets defined.
    • Method that defines Boolean objects gets defined.
      • Return the value after validating the vertices.

Blurred answer
Students have asked these similar questions
Tape for a Turing Machine (Doubly-linked List)”.(I USE ECLIPSE & RUN  CHECK ONLINE CONSOLE)A class named Tape to represent Turing machine tapes. The class should have an instance variable of type Cell that points to the current cell with the method: public Cell getCurrentCell() -- returns the pointer that points to the current cell. public char getContent() -- returns the char from the current cell. public void setContent(char ch) -- changes the char in the current cell to the specified value. Don't forget the Javadoc comments. IT WOULD HAVE A PUBLIC CLASS  public void moveLeft() -- moves the current cell one position to the left along the tape. Note that if the current cell is the leftmost cell that exists, then a new cell must be created and added to the tape at the left of the current cell, and then the current cell pointer can be moved to point to the new cell. The content of the new cell should be a blank space. (Remember that the Turing machine's tape is conceptually…
Complete the Kennel class by implementing the following methods: addDog(Dog dog) findYoungestDog() method, which returns the Dog object with the lowest age in the kennel. Assume that no two dogs have the same age. Given classes: Class LabProgram contains the main method for testing the program. Class Kennel represents a kennel, which contains an array of Dog objects as a dog list. (Type your code in here.) Class Dog represents a dog, which has three fields: name, breed, and age. (Hint: getAge() returns a dog's age.) For testing purposes, different dog values will be used. Ex. For the following dogs: Rex Labrador 3.5 Fido Healer 2.0 Snoopy Beagle 3.2 Benji Spaniel 3.9  the output is: Youngest Dog: Fido (Healer) (Age: 2.0)
Observer pattern The PhoneModel class stores a phone number as a list of digits, and the Keypad class has this method: public void simulateKeyPresses(int numKeyPresses)(0 that allows the user to enter digits one at a time then save each digit in the list. The Screen wants to respond to each key being entered. Make the model notify the observers whenever a new digit is entered for the phone number. The first observer prints the newest digit out to the screen The second observer prints "Now dialing 12345678901.." out to the screen (where the number is the number the model has). Only the Screen class can print to the screen The model must be decoupled from the Other classes.

Chapter 28 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

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