do this in the main from the adt , do the menu and ask the user to choose
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()) f front = newest; // special case of a previously empty queue \} else \{ rear.setNext (newest); // add node at the tail of the list \} rear = newest; // update the reference to the tail node return temp; 3 public void Display() LIstack
temp = new ILstack (); system.out.print ("The required stack data is : Top... ") ; while (!this.isEmpty ()) \{ system.out.print (this.top ()+"\tn); temp.push(this.pop()); while (!temp.isEmpty ()) ( this.push(temp.pop()); System.out.println(".... the bottom "); 1 public boolean search( E key) \& LIstack E temp = new IIstack E(); E element; boolean result=false; while (!this.isEmpty()) \& element=this. top(); if (element. equals (key)) result=true; temp.push (this.pop ()); 3 while (!temp.isempty ()) \& this.push (temp.pop ()) ; ) return result; 1 1 public class Node E I private E element; // reference to the element stored at this node node in the 1 ist * Bauthor Shroo / public class Patient \{ Data private string PatientName; private int PatientID; 11 Constructor public Patient (string PatientName, int PatientID) \& this. PatientName=PatientName; this. PatientID=PatientID; 1 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 (E e) {// adds element e to the front of the 1 ist link a new node newest. setNext (head); head = newest; if ( size ==0) ( tail = head; // special case: new node becomes tail also 3 sizet+; 1 public void addIast(E e) {// adds element e to the end of the 1 ist Node E newest = new Node E(e, nul1 );// node wil1 eventually be the tail if (isEmpty()) 1 head = newest; 1/ special case: previously empty 1ist I else 1 tail. setNext(newest); II new node after existing ta1 1) tail = newest; // new node becomes the tail size+t; 1 public E removeFirst() f I / removes and returns the firat element if (isempty()) 1 return nul1; 11 nothing to remove 1 E answer = head. getelement(); head = head.getNext(); /I wi.11 become nul1 if list had only one node size-; if (size=0) ( tail = nu11; 1/ special case as 1 ist is now empty