this is for Python and can you explain what the code is doing with comments and test case you DONT use any of the list methods (append, pop etc.). class mystack(): def __init__(self, m = 10): self.maxsize = m self.TOP = -1 self.array = [None]*m def push(self, item): # Inserts item at the top of the stack and returns True. If unable to insert the item returns false ####################################################################### # Remove the pass statement and write your code ####################################################################### pass def pop(self): # Removes the item from the top of the stack and returns it. For unsuccessful pop return False ####################################################################### # Remove the pass statement and write your code ####################################################################### pass def peek(self): # Returns the item at the top of the stack without removing it from the stack. If stack is empty return false. ####################################################################### # Remove the pass statement and write your code ####################################################################### pass def isempty(self): # Returns true when stack is empty else returns false ####################################################################### # Remove the pass statement and write your code ####################################################################### pass def isfull(self): # Returns true when stack is full else returns false ####################################################################### # Remove the pass statement and write your code ####################################################################### pass def get_size(self): # Returns the size of the stack and for empty stack returns 0 ####################################################################### # Remove the pass statement and write your code ####################################################################### pass
this is for Python and can you explain what the code is doing with comments and test case you DONT use any of the list methods (append, pop etc.).
class mystack():
def __init__(self, m = 10):
self.maxsize = m
self.TOP = -1
self.array = [None]*m
def push(self, item):
# Inserts item at the top of the stack and returns True. If unable to insert the item returns false
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
def pop(self):
# Removes the item from the top of the stack and returns it. For unsuccessful pop return False
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
def peek(self):
# Returns the item at the top of the stack without removing it from the stack. If stack is empty return false.
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
def isempty(self):
# Returns true when stack is empty else returns false
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
def isfull(self):
# Returns true when stack is full else returns false
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
def get_size(self):
# Returns the size of the stack and for empty stack returns 0
#######################################################################
# Remove the pass statement and write your code
#######################################################################
pass
Trending now
This is a popular solution!
Step by step
Solved in 2 steps