← Back to Data Structures & Algorithms
Question 415
Push onto a Linked-Node Stack
Push onto a Linked-Node Stack
This stack has no array and no capacity - it is a chain of nodes, and the fieldtoppoints at the front of that chain. Only push is missing, and it can never fail, so it returns nothing. Requirements: 1. Completepush(int value)so the new node becomes the front of the chain. 2. The new node's next must point at the old top before top is moved. The Node class is provided - do not rename it and do not add public to it, because a Java source file may contain only one public class. Do NOT write a main method.
Expected Output:
30 -> 20 -> 10 -> null 30 3
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Data Structures & AlgorithmsStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.