In this module, we will cover
- The core idea behind the Stack
- Fundamental operations of a Stack
- Array implementation of a Stack in c++
- Explanation of code
A stack is a list with the restriction that insertions and deletions can be performed in only one position, namely the end of the list called the top. An explanatory video from YouTube.
- push ( equivalent to insert ): data is inserted at the top position
- pop ( equivalent to delete ): deletes the most recently inserted element
Basic operations :
- push( x ) : insert element x at the top of a stack
- pop( ) : removes an element from the top of a stack
- topElement( ) : access the top element of a stack
- isEmpty( ) : check whether a stack is empty
- size( ) : determines the current size of a stack
Explanation of code :
That’s all for this article, after completing Linked List we will implement this again using a Linked list. In the next article, we will discuss the Queue.
So, for now, practice the above problems and if you get stuck then ask your questions through comment section or if you have any content related to the topics discussed above and want to add here, then you can mention in the comment section for which we will be thankful to you.