Linear structures (for example, lists, stacks and queues) are common in everyday life and prevelant through programs, including operating systems.
Submit each of the following practice assignments at codePost.io.
To register for a free codePost account, please follow these instructions.
Watch this short video for a demonstration of submitting an assignment and reviewing the results:
Note, currently, feedback is not visible in Safari.
Use the Stack interface and the AStack class for this assignment. Also, add a toString method into the AStack class that returns a sequence representation of the stack. Do not change the interface and you do not need to make any other adjustments to the class.
Please enter the maximum size for the first stack: 3 You entered 3 AStack (1 element): 0 Index 1 (Top) AStack (2 elements): 0 1 Index 1 2 (Top) AStack (1 element): 0 Index 1 (Top) AStack (2 elements): 0 1 Index 1 3 (Top) AStack (1 element): 0 Index 1 (Top) AStack (0 elements): Index (Top) Please enter the maximum size for the second stack: 8 You entered 8 AStack (1 element): 0 Index s (Top) AStack (2 elements): 0 1 Index s t (Top) AStack (3 elements): 0 1 2 Index s t r (Top) AStack (4 elements): 0 1 2 3 Index s t r e (Top) AStack (5 elements): 0 1 2 3 4 Index s t r e s (Top) AStack (6 elements): 0 1 2 3 4 5 Index s t r e s s (Top) AStack (7 elements): 0 1 2 3 4 5 6 Index s t r e s s e (Top) AStack (8 elements): 0 1 2 3 4 5 6 7 Index s t r e s s e d (Top) AStack (7 elements): 0 1 2 3 4 5 6 Index s t r e s s e (Top) AStack (6 elements): 0 1 2 3 4 5 Index s t r e s s (Top) AStack (5 elements): 0 1 2 3 4 Index s t r e s (Top) AStack (4 elements): 0 1 2 3 Index s t r e (Top) AStack (3 elements): 0 1 2 Index s t r (Top) AStack (2 elements): 0 1 Index s t (Top) AStack (1 element): 0 Index s (Top) AStack (0 elements): Index (Top)
Use the Stack interface, Link class and the LStack class for this assignment. Also, add a toString method into the LStack class that returns a sequence representation of the stack. Do not change the interface and you do not need to make any other adjustments to the class. Note, you do not need to upload Stack.java, nor Link.java.
LStack (1 element): Top -> 1 LStack (2 elements): Top -> 2 -> 1 LStack (1 element): Top -> 1 LStack (2 elements): Top -> 3 -> 1 LStack (1 element): Top -> 1 LStack (0 elements): Top LStack (1 element): Top -> s LStack (2 elements): Top -> t -> s LStack (3 elements): Top -> r -> t -> s LStack (4 elements): Top -> e -> r -> t -> s LStack (5 elements): Top -> s -> e -> r -> t -> s LStack (6 elements): Top -> s -> s -> e -> r -> t -> s LStack (7 elements): Top -> e -> s -> s -> e -> r -> t -> s LStack (8 elements): Top -> d -> e -> s -> s -> e -> r -> t -> s LStack (7 elements): Top -> e -> s -> s -> e -> r -> t -> s LStack (6 elements): Top -> s -> s -> e -> r -> t -> s LStack (5 elements): Top -> s -> e -> r -> t -> s LStack (4 elements): Top -> e -> r -> t -> s LStack (3 elements): Top -> r -> t -> s LStack (2 elements): Top -> t -> s LStack (1 element): Top -> s LStack (0 elements): Top