CSC148 Winter Department of Mathematical and Computational Sciences,
This is because we don't want you to care at all about the implementations of these classes, but instead ONLY use the public methods defined by the Stack or Queue ADTs. (Refer to the readings if you aren't sure what these are.) In particular, this means that you shouldn't try to access any attributes of either class, since the ADT descriptions only define what *operations* (methods) can be used for the ADTs. GENERAL HINT: save values in local variables! Even if you pop an item off of a stack, it's not "gone forever" if you assign it to a variable. """ from typing import Any, Optional from adts import Stack, Queue def 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 """ pass def swap_top_two(stack: Stack) -> None: """Swap the top two elements on Precondition: has at least two items.
>>> stack = Stack()