0% found this document useful (0 votes)
33 views1 page

Stack Using Array Algorithm

Uploaded by

lavanya a
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)
33 views1 page

Stack Using Array Algorithm

Uploaded by

lavanya a
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

EX NO 3: Stack using Array algorithm (for record)

Step 1.Start the program


Step 2.create structure stack with data,next.
Step 3.Initialize topNULL.
Step 4.Display menu
1.Push
2:Pop
3:Display
4:Exit
Step 5. Read choice
Step5.1. Get choice 1 call push() goto step 5
Step5.2. Get choice 2 call pop() goto step 5
Step 5.3. Get choice 3 call display() goto step 5
Step 5.4 Get choice 4 goto step 6
Step 6.stop the program.

Push()
Step 1:If (top <= -1) otherwise goto step 5
Step 1.1:Print “Stack Overflow” and return.
Step 2:Otherwise
Step 2.1:read value.
Step 2.2:Increase the top value.
Step 2.3: stack[top]x.
Step 3:End of push method().
Pop()
Step 1:if (top <= -1) else goto step 2
Step 1.1:print"Stack Underflow" message and return.
Step 2:Otherwise:
Step 2.1:Pop the stack[top] and decrement top
Step 2.2:print the deleted element
Step 3 :End of pop method().
Display()
Step 1:initialize i=top
Step 2:if (i>=0) otherwise goto step 3
Step 1.1: print stack[i]
Step 1.2 decrement i value goto step 2
Step 3: print"Stack is empty"
Step 4: end of display() method.

You might also like