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.9PE
Program Plan Intro

Get bipartite sets

Program Plan:

Exercise.java:

  • Import the required packages.
  • Create a class “Exercise”:
    • Define the main method
      • Define and declare the required vertices.
      • Define and declare the required edges.
      • New graph gets created for the defined edges and vertices.
      • Display the cycle that is found.
  • Define and create the class “UnweightedGraphGetBipartiteSets”
    • Create a new constructor.
    • New graph gets using the constructor.
    • Method to “cloneEdges” gets created.
      • New list gets created.
      • Loop that iterates to add the edges into the list.
      • A neighbor copy of the edges is added.
      • Returns the result of the neighbor copy.
    • Method “getBipartite” gets created.
      • New list is created.
      • Loop that iterates to add the elements into the list.
      • New list that contains the neighbor node, clone edges are created.
      • Loop that iterates to assign the value to the parent node and depth is defined.
      • New queue gets defined.
      • Mark visited node.
      • Loop that iterates to validate the size of the vertices to add the vertices are defined.
      • Loop that validate the whether the queue is empty.
      • Add the neighbor edge into the queue.
      • Validate the visited node using if condition.
        • Add values to the queue
        • Assign the depth value and parent value.
      • Return null if the does not contain bipartite.
      • New list for storing the bipartite value gets created.
      • Loop that iterates to validate the depth.
      • Return the bipartite list after validating using if condition.

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.

Graph.java:

  • A graph interface gets created.
  • Method to return the size gets defined.
  • Method to return the vertices gets defined.
  • Method to return the index gets created.
  • Method to get the neighbor node gets created.
  • Method to get the degree gets created.
  • Method to print the edges.
  • Method to clear the node gets created.
  • Method to add the edges, add vertex gets created.
  • Method to remove the vertices gets defined.
  • Method for the depth first search gets defined.
  • Method for the breadth first search gets defined.

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
(b) Write the method isBalanced, which returns true when the delimiters are balanced and returns false otherwise. The delimiters are balanced when both of the following conditions are satisfied; otherwise, they are not balanced. When traversing the ArrayList from the first element to the last element, there is no point at which there are more close delimiters than open delimiters at or before that point. The total number of open delimiters is equal to the total number of close delimiters. Consider a Delimiters object for which openDel is "<sup>" and closeDel is "</sup>".The examples below show different ArrayList objects that could be returned by calls togetDelimitersList and the value that would be returned by a call to isBalanced.Example 1The following example shows an ArrayList for which isBalanced returns true. As tokens areexamined from first to last, the number of open delimiters is always greater than or equal to the number of close delimiters. After examining all…
] ] is_bipartite In the cell below, you are to write a function "is_bipartite (graph)" that takes in a graph as its input, and then determines whether or not the graph is bipartite. In other words, it returns True if it is, and False if it is not. After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (is_bipartite({"A" : ["B", "C"], "B" : ["A"], "C" : ["A"]}), is_bipartite({"A" : ["B", "C"], "B" : ["A", "C"], "C" : ["A", "B"]})) This should return True False Python Python
1.A) The median of a set of integers is the middle-most integer in size. That is, half the integers in the set are less than or equal to the median, and half the integers are greater than or equal to the median. For example, the median of {99, 1, 10, 6, 2} is 6 since 1 and 2 are smaller than 6 and 10 and 99 are larger than 6. Implement a method median( ) with no parameters that finds and returns the median of the integers in a data array. Use this keyword in meaningfully. Assume that the data array is an instance variable of Data class. Write a parameterized constructor to allocate and assign values to data array. Assume that the array has odd length. Write main () in a separate class constructor to use the Data class.

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