For a stack if we push 1 2 3 4 5 and then pop five times giv

For a stack, if we push 1, 2, 3, 4, 5 and then pop five times, give the order of the elements popped off the stack.

Solution

Answer:

When we pust 1, 2, 3, 4, 5 values into stack then values will be placed in stack like below

5 - stack location 5

4 - stack location 4

3 - stack location 3

2 - stack location 2

1 - stack location 1

When appply pop operationon stack, elements will be popped off like below.

First 5 will be popped then 4 then 3 then 2 then 1.

Becuase stack is a linear data structure and it follows FILO or LIFO. First In Last out mananer or Last In First Out.

Since 1 is stored first so 1 will be the last element to popped off from stack

For a stack, if we push 1, 2, 3, 4, 5 and then pop five times, give the order of the elements popped off the stack.SolutionAnswer: When we pust 1, 2, 3, 4, 5 va

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site