Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider two stacks each of size 5. When you pop an element from the first stack

ID: 3664277 • Letter: C

Question

Consider two stacks each of size 5. When you pop an element from the first stack you multiply it by 3 and add it to the second stack. When you pop an element from the second stack you multiply it by 4 and add it to the first stack. Push numbers 1 to 5 to the first stack in order (i.e., push 1 first, then 2 and so on). Push numbers 6 to 10 to the second stack in order. First pop two numbers from the first stack (remember when you pop a number it is going to be added to the second stack). Then pop three numbers from the second stack (remember when you pop a number it is going to be added to the first stack).

a) What is the value in the top of the first stack?

b) What is the value at the top of the second stack?

c) What is the current size of the first stack?

d) What is the current size of the second stack?

Explanation / Answer

a) What is the value in the top of the first stack?

Ans 36

b) What is the value at the top of the second stack?

Ans No element as current size of second stack will be 4

c) What is the current size of the first stack?

Ans 5

d) What is the current size of the second stack?

Ans 4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote