The Stack Class You will begin by writing a Stack class that stores chars and uses a singly linked list representation.
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
The Stack Class You will begin by writing a Stack class that stores chars and uses a singly linked list representation.
The Stack Class You will begin by writing a Stack class that stores chars and uses a singly linked list representation. The Stack class will have a Node inner class with data that is a single char. The Stack will have one instance variable of type Node which will reference the head of the list (or top of the stack). The Stack class must have exactly the following public methods. - isEmpty() which will retum a boolean - push(char item) - pop() - top () which will return a char. - a correct override of the equals method which will be true if and only if the parameter is a Stack with exactly the same contents as the calling object. - clear() which will pop all items off the stack. The pop and top methods may assume that the stack does have data (which means that your program will have to check for an empty stack before calling them).
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!