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 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 n times and print the string again with its expanded version.
For example:
Input: "Che
Output: Chery
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, ilike:
If there is digit that is not having a parentheses immediately atier it then that digit will be ignored. For example: abcdef
Here are some more inputoutput examples so vou krow kpected input and output
tableInput string,OutputstinparaslebcheaccicceabcabccdcdefinabccomnopabccocdmiophapyhappyMississippi
Hint: Create two Stacks. One to hold Stack of lnteger and ene to hold Stack of String.
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
