Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 10PP
Program Plan Intro

“GroupHolder” class

Program Plan:

  • Import required package.
  • Define “Main” class.
    • Define “GroupHolder” class
      • Create an array list “items” from “GroupHolder” class.
    • Method definition for “findGroupNodeFor”
      • Declare variable using “GroupNode” type.
      • Set node “n” to “null”.
      • Set “found” to “false”.
      • Check condition using “while” loop
        • Compute next node.
        • If “n” equal to “s”, then set “found” to “true”.
          • If found, then returns the value of “n”.
          • Otherwise, returns null.
    • Method definition of “addItem”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • If “n” is null, then add it to “items”.
    • Method definition for “getRepresentative”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • Check condition using “while” loop.
        • Set node to link value at node
          • Finally returns the data at node.
    • Method definition of “getAllRepresentatives”.
      • Create an array list.
      • Add data to “items”.
      • Finally returns the result.
    • Method definition of “inSameGroup”.
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Returns result.
    • Method definition of “union”
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Check condition.
        • Find group node for “r1” and “r2”.
    • Create “GroupNode” class.
      • Declare required variables.
      • Create constructor for “GroupNode” class.
      • Create parameterized for “GroupNode” class.
    • Define main function.
      • Create object “g” from “GroupHolder” class.
      • Add item to “g” by calling the method “addItem”.
      • Display groups by calling the method “getAllRepresentatives”.
      • Join groups by calling the method “union”.
      • Display groups after performing unions operations.
      • Check “a” and “e” is in same group by calling method “inSameGroup”.
      • Check “a” and “f” is in same group by calling method “inSameGroup”.

Blurred answer
Students have asked these similar questions
Provide full C++ code Building a playlist (of songs) using a linked list and making some operations such as adding songs, removing songs, shuffling them, etc. (Some parts of this lab will closely follow lab 08 - it is imperative that you complete that lab before working on this project). A Node representing a song has the following data members (similar to struct Node of lab 08, except it doesn't have one member for storing data): string uniqueID  string songName string artistName int songLength Node* nextNodePtr Your code must have the following three files: Playlist.h - Class declaration for a linked list of Nodes (very similar to lab 08 but with some changes to methods, as described below) with following private data members: private:Node* first;Node* last;int size; Playlist.cpp - Class definition main.cpp - main() function Checkpoint A For checkpoint A, you need to build a playlist (of songs) by readings data members of several songs from a file and printing them. Implement…
Please, help me to do this in Java. Create a program to view the waiting list. The list (5 entries) is created in the program and is an object of the LinkedList class. The list entry is a QueuePerson object that contains the queue's last name, first name, and patronymic fields (of type String), an AddressValue field for the queue's address, and queue priority (int type). In turn, the field of the AddressValue type contains three fields of the String type: the name of the city, the name of the street and the house number, as well as an int type field - the apartment number (if the apartment number is 0, the house in which the subject lives does not have apartments). Entries in the queue are sorted according to priority, and the queue is added last in the queue of its priority. Provide the possibility of receiving so that there is no repetition in the queue by the name of the person on the waiting list, for which use TreeSet.
Explain this code by putting comments in detail. Language used is c++. Topic is Linkedlist   // void deleteByData(int data) {    //     if(head->data == data) {    //         head = head->next;    //     }     //     next = head;    //     Node *prev = next;    //     while (next != NULL) {    //         if (next->data == data) {    //             prev->next = prev->next->next;    //         }    //         prev = next;    //         next = next->next;    //     }    // }; };

Chapter 12 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Background pattern image
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