subject

You're given the code (attached) for the SimpleStack class, a sample native Python implementation of a stack. Your task is to complete a modified version of this code that implements the MinStack class. MinStack works exactly the same as SimpleStack, except that It adds the min method that returns the smallest positive value currently in the stack (you can assume the stack holds only numbers) Fill in an implementation for all the methods in MinStack, and submit min_stack. py to the GradeScope autograder. You may not import any other Python code, or use try...except. The auto-grader will run 5 tests on your code, worth 5 points: 0. Given an empty stack, `min()` should thrown an exception 1. On the stack constructed by "`push(1); push(10); push(-100); push(-10)`", then `min()` should return -100 2. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop()`", then `min()` should return -100 3. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop(); pop()`", then `min()` should return 1 4. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop(); pop(); push(0)`", then `min()` should return 0 Your implementations of push(), pop(), min(), and peek() should have O(1) time complexity. After the due-date I will also grade the time complexity of your code, and this will count for another 5 points.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
Craig keeps missing important staff meetings and getting double-booked for appointments. craig should use scheduling software a database diagramming software a word processor
Answers: 1
question
Computers and Technology, 25.06.2019 08:20
The binary numbering system uses only two symbols—the digits 0 and 1—to represent all possible numbers. - true or false
Answers: 3
You know the right answer?
You're given the code (attached) for the SimpleStack class, a sample native Python implementation of...
Questions
question
Mathematics, 09.11.2019 16:31
question
Mathematics, 09.11.2019 16:31
question
Mathematics, 09.11.2019 16:31
Questions on the website: 13722367