Solution Review: Stack Using Array
Let's discuss in detail how to implement a stack with an array.
We'll cover the following...
We'll cover the following...
Solution
As mentioned in a previous lesson, a typical stack must contain the following functions:
Push(value)Pop()IsEmpty()Top()
We’ll take a close look at these functions individually. But before we that, let’s start with constructing a Stack struct.
Now, let’s implement all operations of the stack ADT.
Time complexities
Let’s look at the time complexity of each stack operation.
| Operation | Time Complexity |
|---|---|
| IsEmpty |