Question: Stack Lab In this lab you will demonstrate your ability to be able to use Stack data - structure concept only. You can use java.util.Stack
Stack Lab
In this lab you will demonstrate your ability to be able to use Stack datastructure concept only. You can use java.util.Stack library and no other libraries are allowed. You are not allowed to use HashMap, TreeMap, List, Node, etc. For this lab you will read a string that can have a positive integer lets say n followed by open parentheses then some string and then close parentheses. Your should use Stack implementation to expand the string by repeating the string inside the parathesis exactly times and print the string again with its expanded version.
For example:
Input: "Chery
Output: Cherry
Assume that:
Input string is always valid
There will be no extra white spaces
Parentheses will be wellformed
string will not contain any digits to be repeated, like:
if there is digit that is not having a parentheses immediately after it then that digit will be ignored. For example: abcdef
Here are some more inputoutput examples so you know expected input and output.
tableInput string,Output stringabcaaaaabcbcbcacacccacccabccdefghabcabccdcdefghabccdmnopabccdcdmnophapyhappyMisisipiMississippi
Hint: Create two Stacks. One to hold Stack of Integer and one to hold Stack of String.
SpecialString.java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
