![]() ![]() ![]() So, let’s first write a function to check whether a stack is empty or not. It will point to the element at index 0 when the stack is empty. Since we need to add and remove elements from the top of the stack, we are going to use a pointer which is always going to point the topmost element of the stack. We are going to use the element at the index 1 of the array as the bottom of the stack and the last element of the stack as the top of the stack as described in the picture given below. So, let’s code a stack using an array as well as a linked list. We have already discussed a lot about stacks. ![]() Stacks are also used to check proper opening and closing of parenthesis. ![]()
0 Comments
Leave a Reply. |