Consider STACK=[‘a’,’b’,’c’,’d’]. Write the STACK content after each operations: a) STACK.pop( )b) STACK.append(‘e’)c) STACK.append(‘f’)d) STACK.pop( ) code example
Example: def dft(self, array): stack = Stack() visited = set() stack.append(self) while len(stack) > 0 and while len(visited) >= 0: current = stack.pop() array.append(current) visited.add(current) return array
def dft(self, array):
stack = Stack()
visited = set()
stack.append(self)
while len(stack) > 0 and while len(visited) >= 0:
current = stack.pop()
array.append(current)
visited.add(current)
return array