Professional Documents
Culture Documents
Let's Browse The Back Button: When The Game Is With Data Structure
Let's Browse The Back Button: When The Game Is With Data Structure
Back Button
When the game is with Data Structure.
A B C D
0 1 2 3
• Sequentially or linearly
• Traverse all the elements in single run only.
What are Stack’s Operations?
POP
PUSH Deleting the element
Inserting the element
Top
begin procedure push: PUSH()
stack, data
if stack is full
return null
endif
top ← top + 1
stack[top] ← data
end procedure
POP
PUSH Deleting the element
Inserting the element
Top
PUSH()
POP
PUSH Deleting the element
Inserting the element
Top
PUSH()
POP
PUSH Top Deleting the element
Inserting the element
POP()
POP
PUSH Deleting the element
Inserting the element
Top
begin procedure pop:
stack
if stack is empty
return null
endif
data ← stack[top]
top ← top - 1
return data
end procedure
POP()
POP
PUSH Deleting the element
Inserting the element
Top
POP()
POP
PUSH Deleting the element
Inserting the element
Top
Stack
01 03
PUSH TOP
PUSH(Stack, Data) PEEK(Stack) / StackTop(Stack)
02 04
POP DISPLAY
POP(Stack) DISPLAY(Stack);
THANK YOU