A stack data type is a list with some restriction in the list's operations. It can only perform the operations from one side, called the top. There are three basic operations in the Stack data type, and they are Top(), Push(), and Pop(). The Top() operation is used to fetch the value of the top position item only, the Push() operation will insert the new item in the top position, and the Pop() operation will remove the item in the top position. The stack is also known as a Last In First Out (LIFO) data type. To support these three operations, we will add one operation to the stack, which is IsEmpty(), to indicate whether the stack has elements or not. Please take a look at the following stack diagram:
As we can see in the preceding Stack diagram, we have storage containing a bunch of numbers. However, the only...