Question: using python Please do the following in sequence 1. Implement stack using user defined functions as demonstrated in the class you may use the online


Please do the following in sequence 1. Implement stack using user defined functions as demonstrated in the class you may use the online book) 2. Add the following functions in your Stack class and implement void printStack(Stack s)-prints the elements in stack s from top to bottom. When printStack returns, s should be unchanged. Stack reverseStack(Stack s)-returns a new stack whose elements are backwards from those in s. Again, s is unchanged. 3. Implement Queue data structure with insert, delete, print,update functions. You may refer to the sample code in the book. run main.py 1 class Stack: 2 def init (self): self.ar 3 Conno Pr def push(self, ite): Plea This function should push the iten to the stack 9 10 your code here def pop(self): 11 12 13 14 15 This function should remove the item at the top of the stack code.ee 16 def peek (el) This Function peeks at the Stack, it should return the item at the top of the stack E 17 18 19 2e 21 22 23 24 25 26 22 det slime se This function should return a poolean and dating whether the stace is empty or not This function should return a boolean indicating whether the stack is empty or not 25 26 27 28 29 #your code here class Queue: def _init (self): self.ar def enqueue(self, item): This function should push the item to the stack 31 32 33 34 35 36 37 38 39 40 41 Hyour code here def dequeue (self): This function should remove the item at the top of the stack 2 1 14 defpeek (self) 15 16 18 59 This function peeks at the state, should return the item at the top of the stack de sempre This function should return coolean tetanghether the stock senas not
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
