Question: // Implement your own stack, CharStack, using Linked list. // You shall not use the default Linked List class from Java. // Element in CharStack

// Implement your own stack, CharStack, using Linked list. // You shall not use the default Linked List class from Java. // Element in CharStack is CharNode which contain a char. public class CharStack { protected CharNode top; public CharStack() { top = null; } // Initialize a new CharStack with a char. // It means the stack will contain an element, a CharNode which carries the input char. public CharStack(char c) { // 1. Filling your code here // 1. End of code } // Initialize a new CharStack with a existing CharStack. It's copying the input CharStack and create a new one. // Hint: // Do not modify the input CharStack public CharStack(CharStack cs) { // 2. Filling your code here // 2. End of code } // Create a CharStack. The stack shall contain all the charactors in input string. // Hint // The last char in string shall be at the top of the stack. public CharStack(String str) { // 3. Filling your code here // 3. End of code } // push a char to the top of the stack public void push(char x) { // 4. Filling your code here // 4. End of code }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!