Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solving it like a beginner programmer not like a Professional programmer, and use the ADT Merging as one of the Data Structure Operations combines data

Solving it like a beginner programmer not like a Professional programmer, and use the ADT
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Merging as one of the Data Structure Operations combines data elements from two data structures into one. Different data structure types can be merged such as, Linked lists, Stacks as well as Queues. Using the required ADTs, Write a Java program that:- - Writing a program that helps to enter patients information: - Write a class patientInfo which contains the following data and methods: - Data: PatientName (String). PatientID (int). - Methods: Getter and Setter for each data item. toString method. - Display this menu: 1: Merging two Single Linked List structure type 2.Merging two Stacks data structure type 3:Merging two Queses data structure type 4:Merging Single Linked List with Stack to Linked List 5:Merging Single Linked List with Queue to Linked List 6:Merging Singly Linked List with Stack only Patient's name that start with S to Queue - Ask the user to choose the data structure type from a given list to be merged. If you choose any of the above options: 1.You must request [the size of data structures and patient information] from the user. 2. Print the data structure before the merge. 3. Print data structure after the merge. Node E newest = new Node E(elem, nul1); if (isEmpty()) \{ front = newest; / / special case of a previously empty queue J else f rear. setNext (newest); I/ add node at the tail of the list ] rear = newest; // update the reference to the tail node return term; 3 system.out.print("The required stack data is: Top...> ") ; 1 public class Node E>1 private E element; // reference to the element stored at this node private Node next; I/ reference to the subsequent node in the 1 ist * Qauthor Shroo */ public class Patient \{ Data private string PatientName; private int PatientID; Const public Patient(string PatientName, int PatientID) \{ this.PatientName=PatientName; this. PatientID=PatientID; 1 1/ Setters public void setPatientName (string PatientName) \{ this. PatientName=PatientName; \} public void setPatientID(int PatientID) \{ this. PatientID=PatientID; \} getters public string getPatientName() \& return this. PatientName; I public int getPatientid() { return this.PatientID; } tostring eoverride public string tostring() l return string. format ("Patient's name : "+this. PatientName+" Patient's ID: "+this. PatientID +" " );} 1 /I update methods public void addFirst(Ee) f// adds element e to the front of the list Node E newest = new Node (e, nul1 );// create and link a new node newest. setNext (head) ; head = newest; if ( size =0) ( tail = head; 1/ special case: new node becomes tail also 3 sizet+; 1 public void addIast (Ee)(// adds element e to the end of the list Node E newest = new Node E(e, nul1); // node wil1 eventually be the tail if (isEmpty ()) ( head = newest; 1/ special case: previously empty 1 ist l else \{ tail. setNext(newest); II new node after existing tail 1 tail = newest; /1 new node becomes the tail size+ti public E removeFirst() f// removes and returns the first element if (isempty()) 1 return null; 1/ nothing to remove ) E answer = head.getelement(); head = head.getNext (); /I wil11 become nul1 if list had only one node size-; if (size=0) tail = nu11; 1/ special case as 1 ist is now empty

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago