Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class for Stack. Stack is a special list that keeps a list of number and maintains the rule of last-n first-out. Think of
Write a class for Stack. Stack is a special list that keeps a list of number and maintains the rule of last-n first-out. Think of them like a pop-up stack of plates at a restaurant; the first plate put in will be the last one pulled out and used. You will need to implement 3 functions._init_push, and pop. _init_0) function will initialize an empty list for storing the numbers. Push function will add one number to the top of the stack, pop function will pop out and return the top item of the stack. (Hint, use a list numberList to store the numbers that you push into the stack, use del numberList[0] to remove the top number, use insert() to push a number to the list). After you finish the implementation, use the following statements to test it. >>stack StackO) >> stack.push (5) >> stack.pop) >> stack.push (7) stack.push (6) > stack pop) stack.pop) >> stack.pop () The stack is empty
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