Question
REQUIREMENTS: Using Python, you will write a program called array-stack.py that implements the stack data structure using an array. Be sure to include the following
REQUIREMENTS: Using Python, you will write a program called array-stack.py that implements the stack data structure using an array. Be sure to include the following stack operations in your Python program: CreateStack() creates an empty stack. Push(S, i) pushes item i on top of the stack S. Pop(S) pops the item that is on the top of the stack S. The operation returns the item. If the stack is empty, then the operation is not allowed (i.e., we get an error). Top(S) we get the value of the item on the top of the stack S without removing it. The stack remains the same. If the stack is empty, then the operation again is not allowed and we get an error. IsStackEmpty(S) returns TRUE if stack S is empty, or FALSE otherwise. IMPLEMENTATION DETAILS: Be sure to include your name, along with the Certificate of Authenticity, as comments at the very beginning of your Python code. Also, if you collaborated with others, be sure to state their names as well. Your program should create a single empty stack. That is, your program should not create more than one stack. Your program should display the following menu (looping continuously until the user selects option E): Enter the letter that corresponds to the desired stack operation: A. Push a number (i.e., integer) on the top of the stack. B. Pop a number (i.e., integer) from the top of the stack. C. Display the value of the number (i.e., integer) on the top of the stack. D. Indicate whether the stack is EMPTY or NOT EMPTY. E. End program. **Note: Your menu logic should accept options A, B, C, D, E (uppercase or lowercase). Anything other than these options should generate the following error message to the user: Invalid option! Please enter A, B, C, D or E.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started