Thank you Written Homework: Stacks 1. Given an initialy empty stack s that accep
ID: 3854150 • Letter: T
Question
Thank you Written Homework: Stacks 1. Given an initialy empty stack s that accepts integers, the following operations are performed: s.push (10) s.push (20) ·push (30) s.push (40) s pop () s pop () s-push (50) s push (60) a-push (70) s pop () s.pop () s-push (80) s.push (90) s-pop () a) Write out the composition of the stack after these operations. b) What sequence of integers was popped off the stack? 2. The string cOMPUTER is subjected to the following sequence of stack operations, beginning with c and working left to right push - push - push - pop - pop push - push - pop push push pop - push What string is produced by the output from the pops of an initially empty stack? 3. Use the operations push, pop, top, and isEmpty to construct pseudocode operations that do each of the following a) Set num to the second element from the top of the stack, leaving the stack without its top two elements. b) Set num to the second element from the top of the stack, leaving the stack unchanged. Focus on Data Structures Page 129Explanation / Answer
1 (a)
s.push(10)
10
s.push(20)
20
10
s.push(30)
30
20
10
s.push(40)
40
30
20
10
s.pop()
30
20
10
s.pop()
20
10
s.push(50)
50
20
10
s.push(60)
60
50
20
10
s.push(70)
70
60
50
20
10
s.pop()
60
50
20
10
s.pop()
50
20
10
s.push(80)
80
50
20
10
s.push(90)
90
80
50
20
10
s.pop()
80
50
20
10
(b) 40,30,70,60,90
2. MOUE
10
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.