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

Stack Implementation Using Array

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)
78 views1 page

Stack Implementation Using Array

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

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

Step [Link] the program


Step [Link] structure stack with data,next.
Step [Link] topNULL.
Step [Link] menu
[Link]
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 [Link] 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