Computer Science, asked by kiranbilse, 5 months ago

Write a function in Python PUSH(Ls), where Ls is a list of numbers. From this list push all numbers

divisible by 5 into a stack implemented by using a list. Display the stack if it has at least one element,​

Answers

Answered by Anonymous
5

Explanation:

Stack in Python

A stack is a linear data structure that stores items in a Last-In/First-Out (LIFO) or First-In/Last-Out (FILO) manner. In stack, a new element is added at one end and an element is removed from that end only. The insert and delete operations are often called push and pop.

Stack in python

The functions associated with stack are:

empty() – Returns whether the stack is empty – Time Complexity : O(1)

size() – Returns the size of the stack – Time Complexity : O(1)

top() – Returns a reference to the top most element of the stack – Time Complexity : O(1)

push(g) – Adds the element ‘g’ at the top of the stack – Time Complexity : O(1)

pop() – Deletes the top most element of the stack – Time Complexity : O(1)

Similar questions