Question: Consider the following implementation of STACK using our own Singly Linked List and fill in the blanks to complete the program class Node { public


Consider the following implementation of STACK using our own Singly Linked List and fill in the blanks to complete the program class Node { public int bookO; public Node next; public Node(int 1) > class mysLL_Stack protected Node head, tail; public mystL_Stack() 3 public void puth(int 1) Node de new Node(1) 1 head null) 1 stored else 3 > public int pop 14(haad null) deleted rompt } public int pop() { // deleteFromHead if(head == null) // empty return -1; int el = head.bookID; if (head == tail) 17 if only one node on the list; head = tail = null; else head = head.next; return el; } public void printAll() { for System.out.printin } 1 public class Stack_using_SinglyLinkedlist { public static void main(String 1 | args) { System.out.println("Define an object named sllstack"); System.out.println("Push le on stack... "); System.out.println("Push 20 on stack... "); System.out.println("Push se on stack... "); System.out.println("Push 10 on stack... "); System.out.println("Push 2e on stack... "); System.out.println("Push 30 on stack... "); . System.out.println(" Print stack: "); System.out.println(" Pop one value: 1); System.out.println("Popped D: System.out.println(" Print stack: "); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
