Question: Create Java class called Queue and Stack that uses Linked List as the underlying data structure. Stack at minimum has 3 operations, top, push and
Create Java class called Queue and Stack that uses Linked List as the underlying data structure. Stack at minimum has 3 operations, top, push and pop and Queue at minimum has 3 operations, peek, enqueue and dequeue. Each of those operations have a O(1) time complexity. You must create your own Linked List class to be used by Stack and Queue.
Write driver class to test your Queue and Stack class.
NOTE:
You cannot use any Java containers.
All operations in your Linked List must be recursive.
Only define operations in Linked List that are require by Queue and/or Stack.
You need to figure out which Linked List to use for Stack and/or Queue which gives you best time and space complexities.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
