Stack wakanda and washington are shown as below Stack wakanda Stack washington w
ID: 3701276 • Letter: S
Question
Stack wakanda and washington are shown as below Stack wakanda Stack washington wall build fools bridges build men wise will have mexico pay for that wall 1. Trace (showing stacks changing details!). Give the final stack (3 stacks) contents of x and washington. Also give the output and the value of k and theword stack x = new Stack() ; string theword -washington.peek for (int i=0; í?3: i++) { x push (theword + wakanda.pop )) Washinton. push ("Oh you don't") int k = washington, size(); while (int í=0; iExplanation / Answer
Solution:
We have the stacks
Wakanda: wise, men, build, bridges, fools, build, wall
Washington: wall, that for, pay, mexico, have, will, I
1)
So in the code theword will have peek at the word I
so theword= "I"
the loop is iterating 3 times
so now, a new stack x will have
X: Iwall, Ibuild, Ifools
and the other two stacks,
Wakanda: wise, men, build, bridges
Washington: wall, that for, pay, mexico, have, will, I
After this oh you don't will be pushed into wahington then everything will be popped from wahington
X: Iwall, Ibuild, Ifools
and the other two stacks,
Wakanda: wise, men, build, bridges
Washington:
2)
notWakanda: wise, build, fools, wall
notused: men, bridges, build
Wakanda:
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.