Posts

Showing posts with the label stack in c

Stack Abstract Data Structure with Array Implementation

Image
Stack is a abstract data type which store the elements in a particular order called Last in first out (LIFO), where insertion is called PUSH operation and deletion called POP operation. The basic operations of stack are: PUSH insert the element into the stack POP deletion of the element from the stack PEEK return the TOP item of the stack Stack implementation can be possible using: Linked List Array Array implementation of stack  has following advantages and disadvantages: Advantages: Best Performance Disadvantage: Fixed Size Stack Applications Compiler (parsing the data between the brackets) Operating system (program stack) Artificial intelligence(finding the path) Stack implementation using an array: First define the size of the array Take a index variable called TOP=-1 If TOP==MAX then stack is full If TOP==-1 stack is empty PUSH operation is performed with increment of TOP POP operation is performed with TOP decrements...