LinkedStack generic class

Create your own LinkedStack generic class: Submit just one file The Java API uses arrays to implement a Stack, while other languages use linked lists, as it can have be an O(constant) structure if done correctly. In this assignment, I want you to create something similar to the LinkedList in Chapter 16, but FAR shorter, no front & back (just top). Enforce the following:1. public LinkedStack implements Iterable (no extends allowed).2. ALL methods in your LinkedStack must be O(constant) complexity.3. NO System calls in your Class, throw Exceptions if errors occur.4. Default constructor creates an empty LinkedStack.5. Follow good coding rules as established back in week #1. Program Submission Requirementsboolean empty()
Tests if this stack is empty.
E peek()
Looks at the object at the top of this stack without removing it from the stack.
E pop()
Removes the object at the top of this stack and returns that object as the value of this function.
E push(E item)
Pushes an item onto the top of this stack.To keep this all in one one class file, you will definitely need to have a couple "inner classes" for the nodes and the iterator. A good example of inner classes is at the end of Chapter 16, look at the example LinkedList.jav

Powered by