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

Stack in C: Presented by Himangku Saikia Manash Jyoti Chetri Sunny Peter Dhanwar Pradyut Prakash Das

This document defines and discusses stacks in C. It defines a stack as an ordered collection where items are inserted and deleted from one end, called the top. The key principle is LIFO (Last In First Out). There are two main operations - PUSH which inserts a new element to the top, and POP which removes the top element. Stacks can be implemented statically using arrays or dynamically using pointers and linked lists. Applications of stacks include converting decimal to binary, infix to postfix expression conversion, expression evaluation, recursion, and modeling real-world LIFO systems like books on a shelf.

Uploaded by

Himangku Saikia
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Stack in C: Presented by Himangku Saikia Manash Jyoti Chetri Sunny Peter Dhanwar Pradyut Prakash Das

This document defines and discusses stacks in C. It defines a stack as an ordered collection where items are inserted and deleted from one end, called the top. The key principle is LIFO (Last In First Out). There are two main operations - PUSH which inserts a new element to the top, and POP which removes the top element. Stacks can be implemented statically using arrays or dynamically using pointers and linked lists. Applications of stacks include converting decimal to binary, infix to postfix expression conversion, expression evaluation, recursion, and modeling real-world LIFO systems like books on a shelf.

Uploaded by

Himangku Saikia
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

STACK IN C

PRESENTED BY Himangku saikia Manash jyoti chetri Sunny peter dhanwar Pradyut prakash das

Definition of stack
Stack is an ordered collection of items into which items may be inserted and from which items may be deleted at one end, called the top of the stack. The other end of the list lies inactive is termed as bottom of stack. PRINCIPLE - LIFO ( Last In First Out ) .

OPERATIONS ON STACK
Mainly the are two operations on stack . They are as follows. 1. PUSH 2. POP

PUSH AND POP OPERATION


PUSH : The procedure of inserting a new element to the top of the stack is known as push operation. In every push operation the top is incremented by one. After every push operation the new element rests at the top. POP: The procedure of removing element from the top of the stack is called as pop operation. After every pop operation the top is decremented by one. Pop operation cannot be applied when the stack is empty or stack underflow.

REPRESENTATION OF STACK IN C

STACK IMPLEMENTATION
The stack implementation is mainly done in two ways. They are as follows. 1.Static implementation. 2.Dynamic implementation.

Static implementation:
Static implementation is a simple method which can be done using arrays,but it has few limitations. During a program execution the size of an array cannot be modified once it has been declared.

DYNAMIC IMPLEMENTATION
1. The dynamic implementation is done using pointers. 2 .On the run time there is no restiction on the number of elements when we are using pointer implementation

3.Memory is allocated only after the element is pushed to the stack.

4.Dynamic memory is efficiently utilized with pointers.

5.Linked list is an eg of this implementation.

APPLICATIONS OF STACK..
STACKS HAVE NUMEROUS APPLICATIONS. WE SEE STACKS IN EVERYDAY LIFE, FROM THE BOOKS IN OUR LIBRARY, TO THE SHEAF OF PAPERS THAT WE KEEP IN OUR PRINTER TRAY. ALL OF THEM FOLLOW THE LAST IN FIRST OUT (LIFO) LOGIC, THAT IS WHEN WE ADD A BOOK TO A PILE OF BOOKS, WE ADD IT TO THE TOP OF THE PILE, WHEREAS WHEN WE REMOVE A BOOK FROM THE PILE, WE GENERALLY REMOVE IT FROM THE TOP OF THE PILE.

A FEW APPLICATIONS OF STACKS IN THE WORLD OF COMPUTERS ARE IN THE NEXT SLIDE.

1.Converting a decimal number to a binary number.


2.Conversion of an Infix expression that is fully parenthesized into a Postfix expression

3. Expression evaluation and syntax parsing

4. recursion

You might also like