from typing import Any, Optional from adts import Stack, Queue def…
Question Answered step-by-step from typing import Any, Optional from adts import Stack, Queue def… from typing import Any, Optionalfrom adts import Stack, Queuedef peek(stack: Stack) -> Optional[Any]: “””Return the top item on the given stack. If the stack is empty, return None. Unlike Stack.pop, this function should leave the stack unchanged when the function ends. You can (and should) still call pop and push, just make sure that if you take any items off the stack, you put them back on! >>> stack = Stack() >>> stack.push(1) >>> stack.push(2) >>> peek(stack) 2 >>> stack.pop() 2 “”” if Stack.is_empty()==True: return None else: return Stack(len(Stack)-1) def reverse_top_two(stack: Stack) -> None: “””Reverse the top two elements on


