Computer Science
Write an algorithm to pop an element from the Stack.
Python Stack
1 Like
Answer
An algorithm to pop an element from the Stack is as follows:
- START
- St_len = len(Stack) #Count the total number of elements in the Stack and checks whether the Stack is empty or not
- if St_len == []: or if not Stack: or If not len(Stack):
print("Stack is empty")
go to step 6 - element = Stack.pop() #Removing last element from top of the Stack
- print(element)
- END
Answered By
1 Like
Related Questions
Can a Stack be used to convert a decimal number into a binary number?
Write an algorithm to push an element into the Stack.
Write an interactive menu-driven program implementing Stack using list. The list is storing numeric data.
Write an interactive menu-driven program to implement Stack using list. The list contains the names of students.