What is the value of the top element after these operations are executed?

You have a stack that contains integer values. The values are pushed onto the stack in the
following order: 2,4,6,8.
The following sequence of operations is executed:
Pop
Push 3
Pop
Push 4
Push 6
Push 7

Pop
Pop
Pop
What is the value of the top element after these operations are executed?

You have a stack that contains integer values. The values are pushed onto the stack in the
following order: 2,4,6,8.
The following sequence of operations is executed:
Pop
Push 3
Pop
Push 4
Push 6
Push 7

Pop
Pop
Pop
What is the value of the top element after these operations are executed?

A.
2

B.
3

C.
6

D.
7



Leave a Reply 10

Your email address will not be published. Required fields are marked *


anon

anon

Correct answer is C. 6

The first pop, pops the 8, leaving 6 top of the stack.
The following Push-Pop and Pushx3-Popx3 results in no net effect so 6 is still on top.

Justin

Justin

As anon says the correct answer is 6

Alek

Alek

I agree with you guys

R

R

Stack uses the First in Last Out method.

Correct answer is 6.

Its like compiling books in a box where in you always pop the books at the top and when you pushed a book, it will be on top.

SirIsaac007

SirIsaac007

Correct this section, please..
the correct answer is 6..

Devanshi

Devanshi

The correct answer is 6 as mentioned in the above comments

Ayaz_Samadli

Ayaz_Samadli

The correct answer must be 6!

AydinNasirzadeh

AydinNasirzadeh

😀
Yeap. The answer should be 6.
By the way, it is nice to see your name right here.

Luthfi Alif

Luthfi Alif

push up

Pro

Pro

6 is the Right answer…

Stack i = new Stack();

i.Push(2);
i.Push(4);
i.Push(6);
i.Push(8);

i.Pop();
i.Push(3);
i.Pop();
i.Push(4);
i.Push(6);
i.Push(7);
i.Pop();
i.Pop();
i.Pop();

foreach(var item in i){
Console.WriteLine(“{0} “, item);
}