Menu

[solved]-Using Python Write Stack Class Named Limitedstack Class Based Upon Liststack Written Class Q39052127

Using Python,

Write a stack class named LimitedStack. This class will be basedupon the ListStack written in class. The LimitedStack willessentially be the same as the ListStack except for the followmethod:

push (itemToPush) – adds itemToPush to the stack. If the stackis full, “shift” all items “down” 1 spot and add the newest item tothe top of the stack, eliminating the previous oldest item from thestack. This method WILL NOT throw an error if called when the stackis full.

Write a test program to test the LimitedStack class. An exampleof this could be:

stack1 = LimitedStack (5)

stack1.push (“x”)

stack1.push (“y”)

stack1.push (“z”)

while not stack1.isEmpty():

print (stack1.peek())

stack1.top()

stack1.push (“a”)

stack1.push (“b”)

stack1.push (“c”)

stack1.push (“d”)

stack1.push (“e”)

stack1.push (“f”)

while not stack1.isEmpty():

print (stack1.peek())

stack1.top()

Expert Answer


Answer to Using Python, Write a stack class named LimitedStack. This class will be based upon the ListStack written in class. The … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *