Stack Data Structure in C++ using link list and array

Опубликовано: 22 Октябрь 2024
на канале: it Tips
99
0

Source Code is available here:
https://www.instms.com/data-structure...
Stack is a data structure that implement LIFO retrieval. In stack the value value which is inserted in last will be retrieved first. In this session we have discussed stack data structure implementation with the help of arrays and link list. In C++ stack implementation can be done using arrays and link list. Stack data structure has two fundamental operations with the help of stack pointer (SP). Thees operations are as.
1. Push
2. Pop
The process of storing data items onto the stack is called push operation. In push operation first stack pointer is moved or can say that incremented by one and then value is saved. Each and every time in push operation first capacity is check.If stack approaches to its maximum limit then a message is displayed that stack is full. Here in this session we have also write down two functions for checking stack full or empty state. In lecture we also discussed that it is not mandatory in stack implementation using link list to specify maximum limit. Because link list is dynamic data structure. But when we will implement stack using array then it is necessary to specify the maximum limit of stack.
The process of retrieving data items from stack is called pop operation. In pop operation first value is fetched and then stack pointer is moved.
Stack data structure has multiple uses.One of most famous use is expression evaluation.