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 data-structure 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 (let's 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 2(r)Y'
Output: Chery
Assume that:
Input string is always valid
There will be no extra white spaces
Parentheses will be well-formed
string will not contain any digits to be repeated, ilike: 2(4)
If there is digit that is not having a parentheses immediately atier it, then that digit will be ignored. For example: abc3def
Here are some more input/output examples so vou krow kpected input and output
\table[[Input string,Outputstin],[5(0)3(bc),paraslebche],[2(03(c)),accicce],[2(abc)2(cd)efgh,abcabccdcdefin],[abc2(co)mno1(p),abccocdmiop],[ha2(p)y,happy],[Mi2(s)|2(s)12(p)|,Mississippi]]
(Hint: Create two Stacks. One to hold Stack of lnteger and ene to hold Stack of String.)
 Stack Lab In this lab you will demonstrate your ability to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!