0% found this document useful (0 votes)
2 views

Stack

The document outlines a simple algorithm for pushing an item onto a stack represented by an array. It initializes an empty array and checks if the stack is full before adding the new item. If the stack is full, it prints a message indicating that the stack is full.

Uploaded by

masunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Stack

The document outlines a simple algorithm for pushing an item onto a stack represented by an array. It initializes an empty array and checks if the stack is full before adding the new item. If the stack is full, it prints a message indicating that the stack is full.

Uploaded by

masunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

To push an item on the stack

myArray=[]

item =int(input(" enter item to push"))

stackfull =10 ' the array does not exceed 10'

basepointer= 0' starting at index 0

toppointer =1 ' initializing toppointer '

If toppointer< stackfull :' checking if array not full

toppointer=toppointer+1' increment toppointer

myArray[toppointer]= item

print ("stack full")

print(my list)

You might also like