Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Program Help please MyStack.java Implement a stack using linked lists data structure. Implement your own linked list. You cannot use Java's java.util.LinkedList. pop(): returns
Java Program Help please
MyStack.java
Implement a stack using linked lists data structure. Implement your own linked list. You cannot use Java's java.util.LinkedList.
- pop(): returns and removes the last value on the stack
- push(String item): Push a given value onto the stack
- isEmpty(): returns true or false depending on if the stack is empty
- printStack(): prints the items on the stack to console
- Handles errors for all possible edge cases (i.e. doesnt throw an unhandled exception to the user)
- MyStack(String[] list): constructor which creates the stack with the items in list on the stack. So if list had {a, b, c} the stack would look like: c on top of b on top of a.
MyQueue.java
Implement a queue using the MyStack.java implementation as your data structure. In other words, your instance variable to hold the queue items will be a MyStack class.
- enqueue(String item): inserts item into the queue
- dequeue(): returns and deletes the first element in the queue
- isEmpty(): returns true or false depending on if the queue is empty
- printQueue(): prints the items in the queue to console
- MyQueue(String[] list): constructor which creates the queue with the items in list in the queue: So if list had {a, b, c} the queue would look like: a first, then b, then c.
MyTest.java
- You can have other methods in this class but will be graded to have a:
- Main method which tests every method you implemented above in MyStack and MyQueue.
- As you test the methods, print to console (1) what you are testing, (2) what value you are expecting, (3) whether your test passed or failed.
- Test for edge cases and clearly state in your comment/print out which edge case youre testing.
Console.pdf
- This file has the print out from the main method in MyTest.java
- Also include an answer to the following questions:
- 1) Show an example screenshot of how you used the debugger in fixing your code with a short description on explaining the bug and how you fixed it.
- 2) What is the runtime MyStack's push method, in Big O?
- 3) What is the runtime MyQueue's dequeue method, in Big O?
- 4) What is the space complexity of MyQueue, in Big O?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started