Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Stack and its operation implemented with array new - Copy.pptx
1.
2.
3. Stack is a linear data structure which means the
data value are arranged in an orderly manner in single
path.
Stack has one door which is responsible for insertion
and deletion of data from list.
Stack follow special mechanism on the list that is
LIFO ( LAST IN FIRST OUT )
4. In LIFO the data came in list lastly in the list will be out
firstly from the list.
5. Top is Special variable of stack which is use to
insert and delete the data value in the list. In
Top, Push() function is used to insert new
elements into stack and pop() function is used
to delete the element from the stack. Both
insertion and deletion are allowed at only one
end of Stack called Top.
6.
7.
8. Stack are basically three
operations that can be
performed on stack –
Push
Pop
Peep
9. push () – push operation is
used to insert the new data in
stack. If the stack is full, then it
is said to be an overflow
condition.
10. pop () – Pop operation is
used to delete the data in
stack. If the stack is empty,
then it is said to be an
underflow condition.
11. peep() - The peep
operation is used to display
all the data of the stack.
12. int arr [5]; int top = -1;
Insertion and deletion at the top of the stack
only.
Initially when the stack is empty, top = -1
For push operation, first the value of top is
increase by 1 and then the new element is
pushed at the position of top.
13. For pop operation, first
the element at the
position of top is popped
and then top is decreased
by 1
Push, check for
overflow.
Pop, operation for
underflow.
17. void push()
{
Int data;
If (top==MAX-1)
{
printf (“n Overflow or Stack is Full”);
}
else
{
prinf(“Enter Element to be pushed:”);
scanf (“%d”, &data);
top++;
a[top] =data;
}
}