Question
IN JAVA The Problem Integer numbers must be loaded into and stored in a stack such that the largest value is always stored at the
IN JAVA
The Problem
Integer numbers must be loaded into and stored in a stack such that the largest value is always stored at the top position (that is the numbers are kept sorted in decreasing order).
The numbers are read by the program from a file. The numbers in the file are not necessarily sorted.
The stack must be linked list based.
Generic implementation is required, that is, the data in the nodes must be objects. Use the Integer type at instantiation for data rather than int.
The implementation must be tested and the result (decreasing storage) verified.
Determine the big-Oh for the performance of your algorithm
Analysis and Design
Make a careful design before implementation. Decide about the classes and additional methods needed to load up the stack.
Write a pseudo-code (attach it as a comment after the Application class).
Implementation and Testing
When a new element is added to the stack, one or more elements may have to be popped, since the new value may not be greater than the current top value. You will need a temporary storage for these popped elements before they can be pushed back. You must use a second stack for temporary storage .
Document your program
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